Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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.

Comment on Re^3: DWIM with non ASCII characters

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://838885]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2014-09-16 16:17 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (33 votes), past polls