note 47141 added to function.utf8-decode
| From: | doberschatgmxdotnet at osu1 dot php dot net | Date: | Thu, 04 Nov 2004 11:54:53 +0000 |
| Subject: | note 47141 added to function.utf8-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-79601@lists.php.net to get a copy of this message | ||
Note that although the doku above says that utf8_decode() decodes data, assumed to be UTF-8 encoded
to ISO-8859-1, the output of iconv() and utf8_decode() in the example below is not equal.
This is especially a problem if you want to decode utf8-encoded data like those google-urls
containing EURO signs like the following one:
http://www.google.de/search?hl=de&q=20+%E2%82%AC&meta=
(use urldecode() on it first)
IMO it's better to use the iconv() function, which is returning the the right data for me...
hope that helps...
<?PHP
print '<pre>';
print_r(iconv_get_encoding()); // 'ISO-8859-1' for input, internal an output here
print '</pre>';
if( iconv("UTF-8","ISO-8859-1", "\xE2\x82\xAC") !=
utf8_decode("\xE2\x82\xAC") ) {
print 'not equal!';
}
else print 'equal!';
?>
----
Manual Page -- http://www.php.net/manual/en/function.utf8-decode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47141
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47141&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47141&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47141&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47141&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47141&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47141&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47141&report=yes
Search -- http://master.php.net/manage/user-notes.php