Today when writing the APIinterface, I converted the PHP array into json, but there is a rule that unicode cannot be used Encoding
Tried several methods:
If PHP is 5.4 or above, you can directly use the JSON_UNESCAPED_UNICODE parameter
json_encode('Chinese test',JSON_UNESCAPED_UNICODE);
This method String is feasible, but array is not feasible (to be verified)
2. Urlencode the string in the array, then convert the array json_encode into json, and finally urldecode
Note: urlencode() and urldecode() convert Chinese characters into hexadecimal and combine strings according to certain rules to achieve character encoding and decoding to ensure the character integrity during URL data transmission. Completeness and Compatibility
The above is the detailed content of Detailed introduction to Chinese characters that are not unicode encoded when PHP outputs json data. For more information, please follow other related articles on the PHP Chinese website!