用php的json_encode来处理中文的时候, 中文都会被编码, 变成不可读的, 类似”\u***”的格式,如果想汉字不进行转码,这里提供三种方法
1.升级php,在php5.4, 这个问题终于得以解决, json新增了一个选项: json_unescaped_unicode, 故名思议, 就是说, json不要编码unicode.
urlencode(我是测试));$array = json_encode($array);echo urldecode($array);//{test:我是测试}
3.对unicode码再进行解码,解码函数如下:
function decodeunicode($str){ return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', create_function( '$matches', 'return mb_convert_encoding(pack(h*, $matches[1]), utf-8, ucs-2be);' ), $str);}4.例子$arr = array('name1':中文,'name2':'abc12');$jsonstr = decodeunicode(json_encode($arr));
http://www.cnblogs.com/sink_cup/archive/2011/05/28/php_json_encode_unicode_decode.html
http://www.veryhuo.com/a/view/35112.html
http://www.alixixi.com/program/a/2011112776664.shtml