【发布时间】:2012-05-02 08:21:09
【问题描述】:
是否可以在 PHP 中将 unicode PCRE 序列(如 \x{2f}、\x{3251})转换为字符串?
【问题讨论】:
是否可以在 PHP 中将 unicode PCRE 序列(如 \x{2f}、\x{3251})转换为字符串?
【问题讨论】:
使用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');
【讨论】: