我想将 Unicode 代码点转换为字符。这是我尝试过的:
$point = dechex(127468); // 1f1ec
echo "\u{1f1ec}"; // this works
echo "\u{$point}"; // this outputs '\u1f1ec'
echo "\u{{$point}}"; // Parse error: Invalid UTF-8 codepoint escape sequence
echo "\u\{{$point}\}"; // outputs \u\{1f1ec\}
echo "\u{". $point ."}"; // Parse error; same as above
最佳答案
您不需要将整数转换为十六进制字符串,而是使用 IntlChar::chr :
echo IntlChar::chr(127468);
直接来自 IntlChar::chr
的文档:
Return Unicode character by code point value
关于PHP Unicode代码点到字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48432078/