Here's the big secret about encodings: You need a priori knowledge of which encoding to use for each specific data stream.

That means, you cannot effectively auto-detect which encoding to use simply by observing the data stream alone. An out-of-band message may be used to signal which encoding to use, as is typical with web browsers using the HTTP protocol.

You pointed out your locale settings and suggested that Perl makes use of them. Having Perl set encodings for STDIN/STDOUT/STDERR based on locale would break any data stream that is not encoded as such. Not to mention, applying encoding to many data streams based on global (locale) settings violates what I mentioned earlier.

By default, Perl assumes every stream has no encoding (1 character per byte) - it's safe (i.e. binary data won't break) and is a reasonable default (i.e. an otherwise implicit encoding based on locale is hard to see).

In reply to Re: why no default unicode? by repellent
in thread why no default unicode? by perl-diddler

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.