When PHP's json_encode is used to process Chinese characters, Chinese characters are encoded and become unreadable. If you want Chinese characters Not To Be transcoded, three methods are provided here. upgrade PHP. In PHP5.4, this problem was finally solved. Json adds an option: JSON_UNESCAPED_UNICODE. Therefore, the name of Json is invalid, that is, Json is not edited.
When PHP's json_encode is used to process Chinese characters, Chinese characters are encoded and become unreadable. If you want Chinese characters Not To Be transcoded, three methods are provided here. upgrade PHP. In PHP5.4, this problem was finally solved. Json adds an option: JSON_UNESCAPED_UNICODE. Therefore, the name of Json is invalid, that is, Json is not edited.
When PHP's json_encode is used to process Chinese characters, Chinese characters are encoded and become unreadable, similar to the "\ u ***" format. If you do not want to transcode Chinese characters, three methods are provided here.
1. Upgrade PHP. In PHP5.4, this problem was finally solved.Solution, Json adds an option: JSON_UNESCAPED_UNICODE, so it is named Unicode, that is, Json does not encode Unicode.
2. urlencode the Chinese characters first and then use json_encode. After json_encode, use urldecode again to decode them. In this way, the Encoded chinese characters in the json array will not undergo unicode encoding.
$ Array = array ('test' => urlencode ("I'm a test"); $ array = json_encode ($ array); echo urldecode ($ array ); // {"test": "I'm a test "}
3. decodes the unicode code. The decoding function is as follows:
Function decodeUnicode ($ str) {return preg_replace_callback ('// \\\ u ([0-9a-f] {4})/I', create_function ('$ matches ', 'Return mb_convert_encoding (pack ("H *", $ matches [1]), "UTF-8", "UCS-2BE"); '), $ str);} 4. example $ arr = array ('name1': "Chinese", 'name2': 'abc12 '); $ jsonstr = decodeUnicode (json_encode ($ arr ));
Http://www.cnblogs.com/sink_cup/archive/2011/05/28/php_json_encode_unicode_decode.html
Http://www.veryhuo.com/a/view/35112.html
Http://www.alixixi.com/program/a/2011112776664.shtml