Is it possible that my shell is interpreting the output differently than perl?

It's all bytes until you pass them to something that cares, such as lc or your shell. Each of those "somethings" will interpret the bytes as it sees fit.

One minor note however, the code I posted was in fact the code that I ran, so I am still confused on that point. I appreciate your help.

There are a number of stetps between the file and Perlmonks where the bytes could have been substituted, plus PerlMonks itself and my browser.

If I insert the semicolon, it prints junk.

So far, we've only covered decoding the source. Sounds like you didn't properly encode the data while printing it. One way:

#!/usr/bin/perl use strict; use warnings; # Decode source from UTF-8. use utf8; # Decode STDIN as per locale. # Encode STDOUT & STDERR as per locale. use open qw( :std :locale ); my $test = '...'; print($test); Dump($test);

Or if you want to decode/encode your input/output using a specific encoding, you can do it as follows:

#!/usr/bin/perl use strict; use warnings; # Decode source from UTF-8. use utf8; # Expect UTF-8 from STDIN. # Send UTF-8 to STDOUT & STDERR. BEGIN { binmode STDIN, ':encoding(UTF-8)' or die; binmode STDOUT, ':encoding(UTF-8)' or die; binmode STDERR, ':encoding(UTF-8)' or die; } my $test = '...'; print($test); Dump($test);

Feel free to replace "..." with characters of your choice. If you're still having problem, please provide the Dump output, a description of what you see from the print (primarily the number of characters you see), how many characters you are expecting to see, and which of the two programs produced the output.


In reply to Re^3: UTF-8 representation question by ikegami
in thread UTF-8 representation question by bpa

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.