php 解码中文单词

php decode chinese words

我正在尝试解码一些中文单词,例如:

\u592a\u5e73\u9053\u5bf5\u7269\u8a3a\u6240\uff0c\u9999\u6e2f\u4e5d\u9f8d\u65fa\u89d2\u81ea\u7531\u90537\u865f\u5730\u4e0bB\u8216\u3002

如何使用Php解码上述中文单词?

您需要使用mb_convert_encodingMore details - mb-convert-encoding

$str = '\u592a\u5e73\u9053\u5bf5\u7269\u8a3a\u6240\uff0c\u9999\u6e2f\u4e5d\u9f8d\u65fa\u89d2\u81ea\u7531\u90537\u865f\u5730\u4e0bB\u8216\u3002';
$str = preg_replace_callback('/\\u([0-9a-fA-F]{4})/', function ($match) {
    return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UTF-16BE');
}, $str);

结果:

echo $str;//太平道寵物診所,香港九龍旺角自由道7號地下B舖。