PHP将PCRE unicode序列转换为普通utf-8字符串

PHP将PCRE unicode序列转换为普通utf-8字符串,php,unicode,utf-8,pcre,Php,Unicode,Utf 8,Pcre,在PHP中是否可以将unicode PCRE序列(如\x{2f},\x{3251})转换为字符串?使用其可能的 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

在PHP中是否可以将unicode PCRE序列(如
\x{2f}
\x{3251}
)转换为字符串?

使用其可能的

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');
示例:

使用其可能的

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');
示例: