0
PHP中是否可以將unicode PCRE序列(如\x{2f}
,\x{3251}
)轉換爲字符串?PHP將PCRE unicode序列轉換爲正常utf-8字符串
PHP中是否可以將unicode PCRE序列(如\x{2f}
,\x{3251}
)轉換爲字符串?PHP將PCRE unicode序列轉換爲正常utf-8字符串
使用html_entity_decode其可能
function cb($a){
$num = $a[1];
$dec = hexdec($num);
return "&#$dec;";
}
$ent = preg_replace_callback("/\\\\x\{([\da-z]+)\}/i", 'cb', "\x{2f}, \x{3251}");
$ustr = html_entity_decode($ent, ENT_NOQUOTES, 'UTF-8');