Php problems, experts help explain the principle of why after url encoding, and then decoding will not appear '\ u51b0 \ u706b \ u56fd \ u5ea6' such characters? PHPcode & lt ;? Php $ data = array ('game' = & gt; 'ice-fire status', 'name' = & gt; 'Thorn-Ling', 'Country' php problems, how it works
Why are there no characters like '\ u51b0 \ u706b \ u56fd \ u5ea6' after url encoding and decoding?
PHP code
'Ice-fire status', 'name' => 'Thorn Ling', 'Country' => 'ice-cream state', 'level' => 45 ); echo json_encode ($ data); echo'
';/*** Handle json_encode garbled characters */$ newData = array (); foreach ($ data as $ key => $ value) {$ newData [$ key] = urlencode ($ value);} echo urldecode (json_encode ($ newData);?> The results show: {"game": "\ u51b0 \ u706b \ u56fd \ u5ea6", "name": "\ u523a \ u4e4b \ u7075", "country ": "\ u51b0 \ u971c \ u56fd", "level": 45} {"game": "Ice Fire country", "name": "thorn spirit", "country ": "Frost country", "level": "45 ″}
------ Solution --------------------
Then you have not printed the data after Encoding. you can immediately decode and print the data after Encoding. urlencode makes all the bytes into common ascii characters, which must be correct.