I'm confused by your code, what is it supposed to demonstrate? perlunitut: Unicode in Perl warns against using is_utf8, so I wouldn't use it

Consider

$ perl -le " print chr hex q/C0/ " | od -tx1 0000000 c0 0d 0a 0000003
when viewed as Windows-1252 it is À

And this

$ perl -le " binmode STDOUT , q/:utf8/; print chr hex q/C0/ " | od -tx +1 0000000 c3 80 0d 0a 0000004
when viewed as Windows-1252 it is À but viewed as UTF-8 it is 
And this

$ perl -MEncode -le " print decode(q/utf8/, chr hex q/C0/ )" | od -tx1 Wide character in print at -e line 1. 0000000 ef bf bd 0d 0a 0000005
when viewed as Windows-1252 it is � but viewed as UTF-8 it is �

If you search for ef bf bd you'll see lots of questions about this erroneous conversion

So if you want to treat chr 192 (  perl -le " print  hex q/C0/ " ) as unicode you have to encode it, because characters 0 to 255 are also valid Latin-1, they are not utf8

$ perl -le " print chr hex q/C0/ " |od -tx1 0000000 c0 0d 0a 0000003 $ perl -le " print chr 255 " |od -tx1 0000000 ff 0d 0a 0000003 $ perl -le " print chr 256 " |od -tx1 Wide character in print at -e line 1. 0000000 c4 80 0d 0a 0000004

Or, if you want chr 192 to return unicode, use encoding pragma ( utf8 pragma doesn't affect chr )

$ perl -le " use encoding q/utf8/; print chr 192 " |od -tx1 0000000 c3 80 0a 0000003

In reply to Re^4: Bug in Template? by Anonymous Monk
in thread Bug in Template? by packetstormer

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.