将 php 中的任何字符串或字符转换为 unicode 代码点
convert any string or a character in php to unicode code points
如何将 php 中的任何字符串或字符转换为 "unicode code points"
例如:字母अ的unicode代码点是0905
A 为 0041
如果我通过 Aअ,我需要一个连续的字符串,这将给我一个输出 00410905
使用这个功能
function Unicode_decode($text) {
return implode(unpack('H*', iconv("UTF-8", "UCS-4BE", $text)));
}
如果你想U+0000
使用这个:
for ($i=0; $i < strlen($word); $i++)
{
$wordConvert = Unicode_decode($word[$i]);
$result .= "U+" . substr($wordConvert, -4, 4) . "<br/>";
}
echo $result;
如何将 php 中的任何字符串或字符转换为 "unicode code points"
例如:字母अ的unicode代码点是0905
A 为 0041
如果我通过 Aअ,我需要一个连续的字符串,这将给我一个输出 00410905
使用这个功能
function Unicode_decode($text) {
return implode(unpack('H*', iconv("UTF-8", "UCS-4BE", $text)));
}
如果你想U+0000
使用这个:
for ($i=0; $i < strlen($word); $i++)
{
$wordConvert = Unicode_decode($word[$i]);
$result .= "U+" . substr($wordConvert, -4, 4) . "<br/>";
}
echo $result;