php5.4 before the Json_encode when the Chinese will be Unicode encoding, Chinese will be encoded, become unreadable, similar to the "\u***" format, but also to a certain extent, increase the amount of data transferred. For example: $val) {$data [$key] = Urlencodeary ($val);} return $data; } else {return UrlEncode ($data);}} $test = Array (0 = "Dalian Weekly water sub-airport" → Renmin road ', 1 = "Operating Hours: 5:10~21:00 fare: 16 yuan departure interval of 20 minutes, full-time departure '); /* encode and decode with regular json_encode|json_decode ["\" \u5927\u8fde\u5468\u6c34\u5b50\u673a\u573a\ "\u2192\u4eba\u6c11\u8def", " \u8fd0\u8425\u65f6\u95f4\uff1a5\uff1a10\uff5e21\uff1a00 \u7968\u4ef7\uff1a16\u5143 \u53d1\u8f66\u95f4\u969420\ U5206\u949f\u4e00\u73ed\uff0c\u5ba2\u6ee1\u968f\u65f6\u53d1\u8f66 "]array (0 =" Dalian Weekly water sub-airport "→ Renmin Road", 1 = " Operating hours: 5:10~21:00 fare: 16 yuan interval 20 minutes, full at any time to leave ',) */$test 1 = json_encode ($test); $test 2 = Json_decode ($test 1, TRUE); echo $ Test1;echo Php_eol;var_export ($test 2); Echo php_eol; /* Myjson|json_decode to encode and decode, but will error json_last_error return (Json_error_syntax = = 4), because "" Dalian weekly water sub-airport "→ Renmin Road" ["" "" Dalian Zhou Water sub-airport "→ Renmin Road", " Operating hours: 5:10~21:00 fare: 16 yuan interval 20 minutes, full time departure "]null*/$test 1_1 = Myjson ($test); $test 2_1 = Json_decode ($test 1_1, TRUE); echo $ Test1_1;echo Php_eol;var_export ($test 2_1); Echo php_eol; /* via Json_enco+pack|json_decodeTo encode and decode, to ensure that the Chinese code will not be encoded, but will be missing operating time data and fares ["\" Dalian weekly water sub-airport \ "→ Renmin Road", "Operating Hours:: ~: Fares: Yuan interval minutes, full time"]array (www.2cto.com 0 ") Dalian Weekly Water Sub-airport "→ Renmin Road", 1 + ' operating Hours:: ~: Fares: The yuan departs every minute, the bus departs at any time ', */function Replaceuni ($str) {return preg_replace ("#\\\u ([ 0-9a-f]+) #ie "," Iconv (' UCS-2 ', ' UTF-8 ', pack (' H4 ', ' \\1 ')) ", $STR);} $test 1_2 = Replaceuni (Json_encode ($test)), $test 2_2 = Json_decode ($test 1_2, TRUE); Echo $test 1_2;echo Php_eol;var_ Export ($test 2_2); Echo php_eol;
http://www.bkjia.com/PHPjc/477796.html www.bkjia.com true http://www.bkjia.com/PHPjc/477796.html techarticle php5.4 before the Json_encode when the Chinese will be Unicode encoding, Chinese will be encoded, become unreadable, similar to the \u*** format, but also to a certain extent, increase the amount of data transferred ...