将php中的任何字符串或字符转换为unicode代码点

时间:2015-08-18 13:00:40

标签: php unicode converter

如何将php中的任何字符串或字符转换为" unicode代码点"

例如:字母un的unicode代码点是0905

且A是0041

如果我通过Aअ,我需要一个连续的字符串,它会给我输出00410905

1 个答案:

答案 0 :(得分:0)

使用此功能

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;