Find a workaround on the Web:
Copy CodeThe code is as follows:
/* Handling Json_encode Chinese garbled */
$data = Array (' Game ' = ' ice Fire country ', ' name ' = ' thorn spirit ', ' country ' + ' frost State ', ' level ' = 45);
echo Json_encode ($data);
echo "
";
$newData = Array ();
foreach ($data as $key = = $value) {
$newData [$key] = UrlEncode ($value);
}
Echo UrlDecode (Json_encode ($newData));
?>
Later consulted others, but also can use Base64 code, but base64 code can not put in the URL, Baidu is such explanation:
The standard Base64 is not intended to be transmitted directly in the URL because the URL encoder will change the "/" and "+" characters in the standard Base64 into forms such as "%XX", and these "%" numbers need to be converted when they are deposited into the database because ANSI SQL has used the "%" number as a wildcard character.
But my data is sent via post, not in the head of HTTP, but in Message-body, so it's not affected.
Json_encode can only accept data in utf-8 format
UrlEncode Base64_encode can only accept arguments of type string, so the entire array cannot be encoded.
http://www.bkjia.com/PHPjc/324558.html www.bkjia.com true http://www.bkjia.com/PHPjc/324558.html techarticle find a solution on the Web: Copy code as follows: PHP/* Processing Json_encode Chinese garbled */$data = array (' Game ' = ' ice Fire country ', ' name ' = ' thorn spirit ', ' country ' = ' ice '). .