将php中的任何字符串或字符转换为unicode代码点 [英] convert any string or a character in php to unicode code points

查看:98
本文介绍了将php中的任何字符串或字符转换为unicode代码点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How to convert any string or a character in php to "unicode code points"

例如:字母अ的unicode代码点为0905

for example : unicode code points of letter अ is 0905

并且A是0041

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

I need a continuous string if i pass Aअ which will give me a output as 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代码点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆