Please read this first.


Encode the string of characters.
use Devel::Peek; my $str = "\326"; Dump $str; # not UTF-8 (1 char is 1 byte) my $utf8 = $str; utf8::upgrade($utf8); Dump $utf8; # upgraded to UTF-8 (1 char is 2 bytes) my $utf8_as_bytes = $str; utf8::encode($utf8_as_bytes); Dump $utf8_as_bytes; # not UTF-8 (2 chars with 1 byte each) __END__ SV = PV(0x8519228) at 0x8061e38 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) PV = 0x852b250 "\326"\0 CUR = 1 LEN = 4 SV = PV(0x84556a0) at 0x8528b40 REFCNT = 1 FLAGS = (PADMY,POK,pPOK,UTF8) PV = 0x852b290 "\303\226"\0 [UTF8 "\x{d6}"] CUR = 2 LEN = 3 SV = PV(0x84556a8) at 0x8528730 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) PV = 0x852b2a0 "\303\226"\0 CUR = 2 LEN = 3

In reply to Re: Why does perl's internal utf8 seem to allow single-byte latin1? by repellent
in thread Why does perl's internal utf8 seem to allow single-byte latin1? by brycen

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.