Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

When you include the use utf8 pragma, all this says to Perl is that your script itself is written in UTF-8. It says nothing about what encoding it used by different filehandles.

Regardless of your environment, handles in Perl default to operating as binary byte streams. (The exact details depend on whether you're on an MS-DOS-like machine or a Unix-like machine, but the results are much the same.) This is documented in PerlIO.

Once upon a time (in Perl 5.8.0), Perl used to automatically pick up the locale from the environment. This was somewhat unpredictable and unexpected, and this feature was removed in the next Perl release (5.8.1).

Now, if you want Perl to sniff your environment you need to explicitly ask for it. With binmode or the open pragma, use the :locale layer.

You might also want to check out the -C command line option which provides some facilities for switching the standard input/output/error handles to UTF-8, either unconditionally or depending on your environment.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

In reply to Re: Default encoding rules leave me puzzled... by tobyink
in thread Default encoding rules leave me puzzled... by kzwix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-24 06:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found