Home>Article>Backend Development> Two implementation methods for converting UNICODE encoding into Chinese characters (php and js)
这篇文章给大家介绍的内容是关于UNICODE编码转换为中文汉字的两种实现方式(php和js),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
PHP的方式为:
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); }
JS的方式为:
小小记录下。。。
相关文章推荐:
The above is the detailed content of Two implementation methods for converting UNICODE encoding into Chinese characters (php and js). For more information, please follow other related articles on the PHP Chinese website!