perl-i18n

Re: getting hex values of non-ascii strings

2002-07-14 03:13:20
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 ∇ 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/


<Prev in Thread] Current Thread [Next in Thread>
  • Re: getting hex values of non-ascii strings, Sean M. Burke <=