只要弄Regex的方法就搞定,把json输出的中文unicode转为字体。- $unicodeChar = "\u56de\u590d\uff1a";
- function unicodeString($str, $encoding=null) {
- return preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/u', create_function('$match', 'return mb_convert_encoding(pack("H*", $match[1]), "utf-8", "UTF-16BE");'), $str);
- }
- echo unicodeString($unicodeChar);
复制代码 |
|