Any way to return PHP json_encode
with encode UTF-8 and not Unicode?
$arr=array('a'=>'á');
echo json_encode($arr);
mb_internal_encoding('UTF-8');
和$arr=array_map('utf8_encode',$arr);
不能解决这个问题.
结果:{"a":"\u00e1"}
Expected result: 100
Any way to return PHP json_encode
with encode UTF-8 and not Unicode?
$arr=array('a'=>'á');
echo json_encode($arr);
mb_internal_encoding('UTF-8');
和$arr=array_map('utf8_encode',$arr);
不能解决这个问题.
结果:{"a":"\u00e1"}
Expected result: 100
{"a":"\u00e1"}
and {"a":"á"}
are different ways to write the same JSON document; The JSON decoder will decode the unicode escape.
In php 5.4+, php's json_encode
does have the JSON_UNESCAPED_UNICODE
option for plain output. On older php versions, you can roll out your own JSON encoder that does not encode non-ASCII characters, or use Pear's JSON encoder and remove line 349 to 433.