将字符串转换为devnagari unicode

我正在尝试获取Devnagari Unicode给定字符串的 。

https://codepoints.net/U+0924

我有字符串=“  ”

如何获取其 Unicode 值 (\u0924)?

我想把它放进去phpjavascript

更新

此外,字符串 =“ tkfO{ ”。这应该返回\u0924\u092A\u093E\u0908

  1. https://codepoints.net/U+0924

  2. https://codepoints.net/U+092A

  3. https://codepoints.net/U+093E

  4. https://codepoints.net/U+0908


qq_花开花谢_0
浏览 69回答 2
2回答

三国纷争

使用mb_ord和比dechexprint dechex(mb_ord("त"));

开满天机

这是PHP中的一种方式:function encodeString($str){&nbsp; &nbsp; $s = iconv('UTF-8', 'UTF-32BE', $str);&nbsp; &nbsp; $nb = strlen($s) / 4;&nbsp; &nbsp; $res = '';&nbsp; &nbsp; for($i=0;$i<$nb;$i++)&nbsp; &nbsp; &nbsp; &nbsp; $res .= encodeChar(substr($s, 4*$i, 4));&nbsp; &nbsp; return $res;}function encodeChar($c){&nbsp; &nbsp; $s = bin2hex($c);&nbsp; &nbsp; while(substr($s,0,2)=='00')&nbsp; &nbsp; &nbsp; &nbsp; $s = substr($s, 2);&nbsp; &nbsp; return '\\u'.$s;}echo encodeString('तपाई');输出:\u0924\u092a\u093e\u0908
打开App,查看更多内容
随时随地看视频慕课网APP