note 36924 added to function.recode-string
| From: | jazfresh at rn2 dot php dot net | Date: | Mon, 27 Oct 2003 15:55:18 +0000 |
| Subject: | note 36924 added to function.recode-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59380@lists.php.net to get a copy of this message | ||
I came across a bug (and workaround) when using recode_string. When converting from utf-8 to
iso-2022-jp, it would always return an empty string (although it would work fine for conversions
from html to utf8). Converting with recode on the command line worked fine, which was odd. I noticed
that if I specified "-v" on the command line, recode stated that it was using libiconv to
do the conversion.
Using "iconv" instead of recode got the right results.
i.e.
Works:
$str = recode_string("html..utf-8", "日本語"); //
Unicode for "Japanese"
Doesn't work:
$str = recode_string("utf-8..iso-2022-jp", $mystring);
Works:
$str = iconv("utf-8", "iso-2022-jp", $mystring);
Don't ask me why. Hope this saves someone some frustrating hours debugging.
----
Manual Page -- http://www.php.net/manual/en/function.recode-string.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36924
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36924&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36924&report=yes
Search -- http://master.php.net/manage/user-notes.php