For perl 5.6.x, thus including UTF-8 support but not coming with Encode, you can use pack. In the following, the first character ("C" or "U") indicates the type of packed string, which will be used for the whole string, the second is a character/byte count of zero. "a*" packs the actual string data.

Actually, that will still work on perl 5.8.x, though the few (well hidden) functions in Encode are a valid alternative. See Messing with Perl's Internals. Somehow I get the feeling they don't like you to mess with this, yourself...


In reply to Re: Recommended way to set the utf8 flag without altering the data by bart
in thread Recommended way to set the utf8 flag without altering the data by borisz

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.