问题
How to convert any string or a character in php to "unicode code points"
for example : unicode code points of letter अ is 0905
and A is 0041
I need a continuous string if i pass Aअ which will give me a output as 00410905
回答1:
Use this function
function Unicode_decode($text) {
return implode(unpack('H*', iconv("UTF-8", "UCS-4BE", $text)));
}
If you want to have U+0000
use this :
for ($i=0; $i < strlen($word); $i++)
{
$wordConvert = Unicode_decode($word[$i]);
$result .= "U+" . substr($wordConvert, -4, 4) . "<br/>";
}
echo $result;
来源:https://stackoverflow.com/questions/32073179/convert-any-string-or-a-character-in-php-to-unicode-code-points