This program
use utf8; chr(192) =~ /\w/;
tells me "Malformed UTF-8 character (unexpected non-continuation byte 0x00 after start byte 0xc0) in pattern match (m//)"

As documented in perlfunc, chr seems to take Unicode characters just fine, producing legal UTF-8 for most values, but for some reason is working wrong for arguments in the range 191 through 255.

Here is more proof:

foreach (90, 192, 257, 0x263a) { print "$_ - ", join ('.',unpack('C*', +chr($_))),"\n" }
gives me:
90 - 90
192 - 192
257 - 196.129
9786 - 226.152.186
Note that 192 maps to a single 192 byte, not 195.128.

What's up?

—John


In reply to problem with chr function by John M. Dlugosz

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.