Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Pragma to handle unicode characters

by ikegami (Pope)
on Dec 22, 2008 at 01:32 UTC ( #731950=note: print w/ replies, xml ) Need Help??


in reply to Pragma to handle unicode characters

:utf8 on input is insecure.

binmode STDIN, ":utf8"; binmode STDOUT, ":utf8";

should be

binmode STDIN, ":encoding(UTF-8)"; binmode STDOUT, ":encoding(UTF-8)"; binmode STDERR, ":encoding(UTF-8)";

and can be replaced with

use open ':std', ':encoding(UTF-8)';

or better yet

use open ':std', ':locale';

:utf8 on input is insecure.
open(IN, "<utf8", "sample.txt");

should be

open(IN, "<:encoding(UTF-8)", "sample.txt");

and can be replaced with

use open IO => ':encoding(UTF-8)';

or

use open IO => ':locale';

use utf8;
indicates the source file is encoded using UTF-8. Without it, Perl assumes it's encoded using iso-latin-1.

None of the above decodes the content of @ARGV, data read from open(FH, '-') or data read via <>. The last is being worked on.


Comment on Re: Pragma to handle unicode characters
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2014-07-14 09:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (257 votes), past polls