Re: getting hex values of non-ascii strings

[email protected] ("Sean M. Burke") Sun, 14 Jul 2002 04:12:49 -0600
Newsgroups perl.i18n
Message-ID <[email protected]>
At 16:13 2002-06-17 -0700, Mags Doheny wrote:
>[...]I need to get the (two-digit, i.e. per-byte) hex values of non-ascii 
>strings.[...]

I think what you're asking for is the utf-8 values of the bytes that encode 
a given character.  If that's what's your asking:

perl -e "print join ' ', map sprintf('%02x', $_), unpack 'C*', chr(0x2112)"
e2 84 92

That's basically the incantation I used for generating the "UTF8 Encoding" 
column in the "ASCII [etc] Table" appendix of /Perl and LWP/ (where you can 
see exactly what a &nabla; looks like! hooboy!).

If that bit of code doesn't work the same for you, I bet you're using too 
early a version of Perl.  I'm using a 5.6.1.  Anything before that is scary.
--
Sean M. Burke    http://www.spinn.net/~sburke/