Call the encapsulated interface, need to be converted to JSON format, using Json_encode (), but the passed Chinese is encoded, this is because the PHP json_encode to handle the Chinese language, the Chinese will be encoded, become unreadable, similar to "\u***" format, Chinese does not transcode ; Workaround: 1. Upgrade PHP, above the PHP5.4 version, this problem is finally resolved, JSON added an option: Json_unescaped_unicode, so the name Incredibles, that is, JSON do not encode UNICODE.
<? PHP Echo json_encode ("Chinese", json_unescaped_unicode);//Chinese
2. Decode the Unicode code and decode the function as follows: Json_encode ($STR) decoding Chinese into Chinese
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);}
3. UrlEncode the Chinese characters first and then use the Json_encode,json_encode again after using the UrlDecode to decode, so that the encoded JSON array of Chinese characters will not appear Unicode encoding.
$array Array ( ' test ' =urlencode("I am Testing")); $array = Json_encode ($arrayechourldecode($array// {"Test": "I am a Test"}
Or
$array Array
' Test ' =urlencode("I am Testing")
); $data Array (); foreach ($arrayas$key=$value) { $dataUrlEncode ($value);} Echo UrlDecode (Json_encode ($data));
PHP json_encode processing in Chinese