Why does this:
<?
var_dump ( json_decode('{"unicode":"\u30d7\u30ec\u30b9\u30ad\u30c3\u30c8"}') );
?>
give me:
object(stdClass)#1 (1) {
["unicode"]=>
string(18) "ãã¬ã¹ããã"
}
when according to the docs it should be “プレスキット”
This happens to me on one machine running PHP 5.1.6 with this module installed as per the instructions on http://www.aurore.net/projects/php-json/ and on a machine running PHP 5.2.11
You need to let the browser know to interpret the data as UTF-8 by sending an HTTP header prior to outputting the actual JSON like so:
Note that headers must be sent before any other output. You should probably read up on the HTTP spec and learn about how headers are used. Here’s a link to get you started with sending HTTP headers in PHP.
UPDATE
In an instance like this where the correct headers have been sent, it’s important to make sure the locale settings on your testing machine allow for UTF-8 characters. If the default locale on your system doesn’t support UTF-8 and you don’t have one installed that does, you’ll never see the correct output. You can read a little more about this here