Use oct instead of eval.
Use Encode's encode to find the UTF-8 encoding.

use Encode qw( encode ); my $unicode_codepoint_hex_lit = '0x20ac'; my $unicode_codepoint_integer = oct( $unicode_codepoint_hex_lit ); my $unicode_char = chr( $unicode_codepoint_integer ); my $utf8_bytes = encode( 'UTF-8', $unicode_char ); my @utf8_bytes = map ord, $utf8_bytes =~ /./sg; my @nohi_bytes = map $_ & 0x7F, @utf8_bytes; print(join(' ', map sprintf('%02X', $_), @utf8_bytes), "\n"); print(join(' ', map sprintf('0x%02X', $_), @utf8_bytes), "\n"); print(join(' ', map unpack('B8', pack('C', $_)), @utf8_bytes), "\n"); print("\n"); print(join(' ', map sprintf('%02X', $_), @nohi_bytes), "\n"); print(join(' ', map sprintf('0x%02X', $_), @nohi_bytes), "\n"); print(join(' ', map unpack('B8', pack('C', $_)), @nohi_bytes), "\n");
E2 82 AC 0xE2 0x82 0xAC 11100010 10000010 10101100 62 02 2C 0x62 0x02 0x2C 01100010 00000010 00101100

In reply to Re: Need Help With Seemingly Bizarre Unicode Task by ikegami
in thread 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.