Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^3: DWIM with non ASCII characters

by moritz (Cardinal)
on May 07, 2010 at 07:58 UTC ( #838885=note: print w/replies, xml ) Need Help??

in reply to Re^2: DWIM with non ASCII characters
in thread DWIM with non ASCII characters

Why use utf8;? As I understand the documentation, its purpose is to enable the source code to be in UTF-8

Yes, that way you avoid concatenating decoded and non-decoded strings.

Of course it requires your script to be actually stored in UTF-8. But since the more general solution (use encoding $your_encoding) is severly broken (wrt to AUTOLOAD, thread safety and other issues), that's currently the only sane way to store non-ASCII Perl programs.

As for the rest, I can only agree to what ikegami wrote; using IO layers is much more convenient than using encode() and decode() on every IO operation. More importantly since there are fewer spots you have to care about encoding, the probability of forgetting it somewhere (and getting Mojibake in response) is much lower.

Perl 6 - links to (nearly) everything that is Perl 6.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://838885]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2018-05-26 16:26 GMT
Find Nodes?
    Voting Booth?