During writing and API interfaces today, PHP arrays are converted to json, but there is a rule that unicode encoding cannot be used. during writing and API operations today, PHP arrays are converted to json, however, there is a rule that unicode encoding is not supported.
I tried several methods:
If PHP is more than 5.4, you can directly use the JSON_UNESCAPED_UNICODE parameter.
Json_encode ('Chinese test', JSON_UNESCAPED_UNICODE );
This method is feasible for strings, but the array is not feasible (to be verified)
2. urlencode the string in the array, convert the json_encode of the array to json, and then perform urldecode.
Note: urlencode () and urldecode () convert Chinese characters to hexadecimal notation and combine strings according to certain rules to implement character encoding and decoding, ensure character integrity and compatibility during URL data transmission
The above method does avoid unicode encoding for Chinese characters, but I still failed to pass the test at the end of the interface. Instead, I can use the normal json_encode to avoid mistakes, I will continue my research in the future ·····
The above is the detailed description of the unicode encoding method not used in Chinese when PHP outputs json data. For more information, see other related articles in the first PHP community!