Click to See Complete Forum and Search --> : Convert UTF8 characters to Hexadecimal


flashkid
08-11-2005, 02:59 AM
I want to convert UTF8 characters to Hexadecimal numbers. For example:

if I have a string like:

HI

I want the Hex to be like :

\u0048\u0049

Can this be done?

Thanx

rigadon
08-11-2005, 04:14 AM
Not great but you should be able to make it work:

my $hex = join(' ', map { sprintf('%lx', ord $_) } split('', 'HI'));