Found a solution online:
Copy code The code is as follows:
/* Processing json_encode Chinese garbled code*/
$data = array ('game' => 'Ice and Fire Country', 'name' => 'Thorn Spirit', 'country' => 'Frost Country', 'level' => 45 );
echo json_encode ( $data );
echo "
";
$newData = array ();
foreach ( $data as $key => $value ) {
$newData [$key] = urlencode ( $value );
}
echo urldecode ( json_encode ( $newData ) );
?>
Later, I asked others for advice, and I can also use base64 encoding, but base64 encoding cannot be placed in the URL. Baidu explained this:
Standard Base64 is not suitable for transmission directly in the URL, because the URL The encoder will convert the "/" and "+" characters in standard Base64 into a form such as "%XX", and these "%" characters need to be converted when they are stored in the database, because ANSI SQL has The "%" sign is used as a wildcard character.
However, my data is sent via POST and is not in the HTTP head, but in the message-body, so it is not affected.
json_encode can only accept data in utf-8 format
urlencode base64_encode can only accept string type parameters, so the entire array cannot be encoded.
http://www.bkjia.com/PHPjc/324558.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324558.htmlTechArticleI found a solution on the Internet: Copy the code as follows: ?php /* Process json_encode Chinese garbled characters*/ $ data = array ('game' = 'Ice and Fire Country', 'name' = 'Thorn Spirit', 'country' = 'Ice...