Php does not escape the json encoding method of Chinese characters. Although the latest PHP5.4 supports JSON Chinese encoding, it uses the JSON_UNESCAPED_UNICODE parameter, for example, json_encode (Chinese, JSON_UNESCAPED_UNICODE) for earlier PHP versions, although the latest PHP 5.4 supports JSON Chinese encoding, it uses the JSON_UNESCAPED_UNICODE parameter, for example:
Json_encode ("Chinese", JSON_UNESCAPED_UNICODE) for earlier PHP versions, the processing does not escape the json encoding of Chinese characters. I have written this article about PHP output of Chinese JSON strings, here is a more perfect method:
/**
* Json encoding method without escaping Chinese characters
* @ Param array $ array to be encoded
* @ Return string
*/
Function encode ($ arr ){
$ Str = json_encode ($ arr );
$ Search = "# \\\ u ([0-9a-f] +) # ie ";
$ Replace = "iconv ('ucos-2', 'utf-8', pack ('h4 ',' \ 1 '))";
Return preg_replace ($ search, $ replace, $ str );
}
Source: Mango Xiaozhan
PHP 5.4 already supports JSON Chinese encoding, that is, using the JSON_UNESCAPED_UNICODE parameter, for example: json_encode (Chinese, JSON_UNESCAPED_UNICODE) for earlier PHP versions ,...