- querys.json:
- {"cities":["\u4e0a\u6d77","\u4e1c\u839e","\u4e2d\u5c71","\u4e3d\u6c34","\u4e4c\u9c81\u6728\u9f50","\u4f5b\u5c71","\u4fdd\u5b9a","\u5170\u5dde","\u5317\u4eac","\u5357\u4eac","\u5357\u5b81","\u5357\u660c","\u5357\u901a","\u8d35\u9633","\u8fde\u4e91\u6e2f","\u90a2\u53f0","\u90af\u90f8","\u90d1\u5dde","\u91cd\u5e86","\u91d1\u534e","\u94f6\u5ddd","\u9547\u6c5f","\u957f\u6625","\u957f\u6c99","\u9752\u5c9b"]}
2,php汉字转码文件 test.php
php - header("content-Type: text/html; charset=Utf-8");
- set_time_limit(0); //设定一个程式所允许执行的秒数,0为最大限度
$file = "querys.json"; - $content = file_get_contents($file);
- echo $content."
"; function replace_unicode_escape_sequence($match){ - return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
- }
- $str = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $content);
- echo $str;
- ?>
|