I am trying to get the Devnagari Unicode of a given string.
I have string = "त"
How do I get its Unicode value (\u0924)?
I would like to get it in php or javascript.
Update
Also, string = "tkfO{". This should return \u0924\u092A\u093E\u0908.
I am trying to get the Devnagari Unicode of a given string.
I have string = "त"
How do I get its Unicode value (\u0924)?
I would like to get it in php or javascript.
Update
Also, string = "tkfO{". This should return \u0924\u092A\u093E\u0908.
Here's a way in PHP:
function encodeString($str)
{
$s = iconv('UTF-8', 'UTF-32BE', $str);
$nb = strlen($s) / 4;
$res = '';
for($i=0;$i<$nb;$i++)
$res .= encodeChar(substr($s, 4*$i, 4));
return $res;
}
function encodeChar($c)
{
$s = bin2hex($c);
while(substr($s,0,2)=='00')
$s = substr($s, 2);
return '\\u'.$s;
}
echo encodeString('तपाई');
Output: \u0924\u092a\u093e\u0908
use mb_ord and than dechex
print dechex(mb_ord("त"));