note 77581 added to function.mb-detect-encoding
| From: | rl at itfigures dot nl | Date: | Tue, 04 Sep 2007 21:00:15 +0000 |
| Subject: | note 77581 added to function.mb-detect-encoding | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130182@lists.php.net to get a copy of this message | ||
I used Chris's function "detectUTF8" to detect the need from conversion from utf8 to
8859-1, which works fine. I did have a problem with the following iconv-conversion.
The problem is that the iconv-conversion to 8859-1 (with //TRANSLIT) replaces the euro-sign with
EUR, although it is common practice that \x80 is used as the euro-sign in the 8859-1 charset.
I could not use 8859-15 since that mangled some other characters, so I added 2 str_replace's:
if(detectUTF8($str)){
$str=str_replace("\xE2\x82\xAC","€",$str);
$str=iconv("UTF-8","ISO-8859-1//TRANSLIT",$str);
$str=str_replace("€","\x80",$str);
}
If html-output is needed the last line is not necessary (and even unwanted).
----
Server IP: 83.137.20.107
Probable Submitter: 82.148.212.68
----
Manual Page -- http://www.php.net/manual/en/function.mb-detect-encoding.php
Edit -- https://master.php.net/note/edit/77581
Del: integrated -- https://master.php.net/note/delete/77581/integrated
Del: useless -- https://master.php.net/note/delete/77581/useless
Del: bad code -- https://master.php.net/note/delete/77581/bad+code
Del: spam -- https://master.php.net/note/delete/77581/spam
Del: non-english -- https://master.php.net/note/delete/77581/non-english
Del: in docs -- https://master.php.net/note/delete/77581/in+docs
Del: other reasons-- https://master.php.net/note/delete/77581
Reject -- https://master.php.net/note/reject/77581
Search -- https://master.php.net/manage/user-notes.php