假设我有一对代理。例如:
\u306f\u30fc
有没有可以用来将字符打印到屏幕上的功能?
如果您想手动执行此操作:
echo chr(0x30) . chr(0x6f) . chr(0x30) . chr(0xfc);
如果你有字符串,你总是可以这样做:
$callback = function($match) {
return chr(hexdec($match[1])) . chr(hexdec($match[2]));
}
preg_replace_callback('#\\\\u([0-9a-f]{2})([0-9a-f]{2})#', $callback, $string);
或者,如果 php < 5.3
$callback = create_function('$match',
'return chr(hexdec($match[1])) . chr(hexdec($match[2]));'
);
preg_replace_callback('#\\\\u([0-9a-f]{2})([0-9a-f]{2})#', $callback, $string);