Hi,

On 8/12/07, Gunter Sammet <[EMAIL PROTECTED]> wrote:
> Hi all:
> We noticed yesterday on the IRC chat (zftalk) that there is an issue with
> Zend_Json::encode:
>
>         $test = array("test à test");
>         $test2 = Zend_Json::encode($test);
>         print_r($test);
>         print('<br>Encoded array: ' . $test2);
>
> $test2 contains only 'test '. This was done on PHP 5.2.1. Checking the
> source code revealed that the encode function uses json_encode if existent.
> Looking in the php docs (
> http://ca3.php.net/manual/en/function.json-encode.php) I
> found the following comment:
>
> <snip>
> Take care that json_encode() expects strings to be encoded to be in UTF8
> format, while by default PHP strings are ISO-8859-1 encoded.
There is no "default" PHP strings encoding. PHP strings are byte-safe
and store exactly thus sequence of bytes the parser loads. What you
need is to save your file in UTF-8 encoding or use either mbstring or
iconv extension to convert the chars to UTF-8.

Sincerely,
Alex

-- 
http://www.alexatnet.com/ - consulting, blog, articles and support for
PHP, ZF, JavaScript and web development.

Reply via email to