Find a solution on the Internet:
Copy codeThe Code is as follows: <? Php
/* Process json_encode Chinese garbled characters */
$ Data = array ('game' => 'Ice-fire status', 'name' => 'thorn spirit ', 'country' => 'Ice-frome status ', 'level' => 45 );
Echo json_encode ($ data );
Echo "<br> ";
$ NewData = array ();
Foreach ($ data as $ key => $ value ){
$ NewData [$ key] = urlencode ($ value );
}
Echo urldecode (json_encode ($ newData ));
?>
Later, I consulted someone and I could use base64 encoding. However, base64 encoding cannot be placed in URLs. Baidu explained this as follows:
The standard Base64 is not suitable for direct transmission in the URL, because the URL encoder will convert the "/" and "+" characters in the standard Base64 into the form of "% XX, these "%" signs need to be converted when they are stored in the database, because "%" has been used as a wildcard in ansi SQL.
However, my data is sent through POST, not in the HTTP head, but in the message-body, so it is not affected.
Json_encode can only accept UTF-8 data
Urlencode base64_encode can only accept parameters of the string type, so the entire array cannot be encoded.