I have a hexadecimal string representation of a Unicode codepoint:

my $unicode_character_hexadecimal_string = '0x20ac';
First, I want to convert this hexadecimal string representation of a Unicode codepoint to an integer. Easy enough:

my $unicode_codepoint_integer = eval $unicode_character_hexadecimal_string;
Right?

From here, I want to get to some hexadecimal string representation of the UTF-8 encoding of this Unicode codepoint:

'0xE2 0x82 0xAC'
or perhaps simply

'E2 82 AC'
Then, as strange as it seems, I want to get to an analagous hexadecimal string representation of the same sequence of bytes with the most significant bit turned off (i.e, with 0x80 substracted):

'0x62 0x02 0x2C'
or

'62 02 2C'
Oh, and along the way, I also want to get binary string representations of the same values:

'11100010 10000010 10101100'
and
'01100010 00000010 00101100'
Finally, I want to print the Unicode (UTF-8) characters alongside these various string representations.

I'm trying to generate a kind of metavalue table. You have to trust me: I really do want to do exactly what I've outlined above. I'm using Perl 5.8.8 (ActivePerl build 822).

Thanks.

Jim


In reply to Need Help With Seemingly Bizarre Unicode Task by Jim

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.