$_ = "This line contains 0xC30x86n exotic character."; s/0x([0-9a-fA-F]{2})/chr(hex($1))/eg; utf8::decode($_);

You could create an HTML from that string as follows:

use HTML::Entities qw( encode_entities ); open(my $fh, '>:encoding(UTF-8)', 'file.html') or die; print $fh qq{<meta http-equiv="Content-Type" content="text/html; chars +et=UTF-8">\n}; print $fh qq{<title>Test</title>\n}; print $fh encode_entities($_); # Escapes &<>'"

The file will contain

3C 6D 65 74 61 20 68 74-74 70 2D 65 71 75 69 76 <meta http-equiv 3D 22 43 6F 6E 74 65 6E-74 2D 54 79 70 65 22 20 ="Content-Type" 63 6F 6E 74 65 6E 74 3D-22 74 65 78 74 2F 68 74 content="text/ht 6D 6C 3B 20 63 68 61 72-73 65 74 3D 55 54 46 2D ml; charset=UTF- 38 22 3E 0D 0A 3C 74 69-74 6C 65 3E 54 65 73 74 8">..<title>Test 3C 2F 74 69 74 6C 65 3E-0D 0A 54 68 69 73 20 6C </title>..This l 69 6E 65 20 63 6F 6E 74-61 69 6E 73 20 26 41 45 ine contains &AE 6C 69 67 3B 6E 20 65 78-6F 74 69 63 20 63 68 61 lig;n exotic cha 72 61 63 74 65 72 2E racter.

The HTML reader will render it as

This line contains Æn exotic character.


In reply to Re: Evaluating UTF codes in a file by ikegami
in thread Evaluating UTF codes in a file by Anonymous Monk

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.