Jump to content

ascii to utf-8


alin19

Recommended Posts

i get this text from an email:

"STARTSMS ££££ ENDSMS"

and the write it into a file, but i get:

"STARTSMS =A3=A3=A3=A3 ENDSMS"

 

this is actually a larger part of the email that i get from the server:

Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

STARTSMS =A3=A3=A3=A3 ENDSMS
=0A=0A=0A      
--0-1766339983-1270731703=:14998
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

 

i tryed like this:

$input = file_get_contents("php://stdin");

mb_convert_encoding($input, "UTF-8", "ASCII");

$fp=fopen("test.txt","w");

fwrite($fp,mb_detect_encoding($input));
fwrite($fp,"\n\n".$input);

fclose($fp);

but in the file i still file ASCII

 

and the wrong text.

 

Need some help

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/198018-ascii-to-utf-8/
Share on other sites

i have made some progress :

 

$input=utf8_decode(quoted_printable_decode (file_get_contents("php://stdin")));

 

will get me the string into: ISO-8859-1 (this is the format that i need);

 

but  still there is a problem : "€" is shown as "?"

 

any ideea?

 

Later edit:

 

$input=utf8_decode ("€");

 

$input=quoted_printable_encode($input);

 

echo bin2hex(utf8_decode(quoted_printable_decode($input)));

 

this script

outputs 3F that is the hex for "?";

 

for  € should be "80"

 

any idea ?

Link to comment
https://forums.phpfreaks.com/topic/198018-ascii-to-utf-8/#findComment-1039088
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.