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');and $arr=array_map('utf8_encode',$arr); does not fix it.
Result: {"a":"\u00e1"}
Expected result: {"a":"á"}
{"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_encodedoes have theJSON_UNESCAPED_UNICODEoption 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.