龍巖易富通網(wǎng)絡(luò)科技有限公司

龍巖小程序開發(fā),龍巖分銷系統(tǒng)

php 將 unicode 字符串轉(zhuǎn)中文的方法

2025.05.18 | 63閱讀 | 0條評(píng)論 | php

$txt = "\u7cfb\u7edf\u7e41\u5fd9\uff0c\u8bf7\u7a0d\u540e\u91cd\u8bd5";


function u2c($str)

{

return preg_replace_callback(

"#\\\u([0-9a-f]{4})#i",

function ($r) {

return iconv('UCS-2BE', 'UTF-8', pack('H4', $r[1]));

},

$str

);

}


echo u2c($txt);

轉(zhuǎn)后后顯示中文“系統(tǒng)繁忙,請(qǐng)稍后重試”


贊 (

發(fā)表評(píng)論