develooper Front page | perl.perl5.porters | Postings from September 2010

[perl #43248] utf8 encoding and the -i switch

Thread Next
Father Chrysostomos via RT
September 26, 2010 13:46
[perl #43248] utf8 encoding and the -i switch
Message ID:
On Tue Jun 19 00:14:20 2007, wrote:
> This is a bug report for perl from,
> generated with the help of perlbug 1.35 running under perl v5.8.8.
> % cat datei
> eine test datei
> die "u "a "o
> % file datei
> datei: ASCII text
> % cp datei datei.bk
> % perl -wpi -e 'use encoding "utf8"; s/"a/ä/' datei
> % file datei
> datei: ISO-8859 text
> % perl -wp -e 'use encoding "utf8"; s/"a/ä/' datei.bk > datei.neu
> % file datei.neu
> datei.neu: UTF-8 Unicode text
> my xterm is also utf8; I think both files should be utf8, i dont know
> why "datei" is changed to latin1.

‘use encoding "utf8"’ tells perl that the script you are giving it to
run is in UTF-8 encoding. It does not affect the input and output
streams. For that, try ‘use open ":utf8"’. See also ‘perldoc -f binmode’
and the -C option in perlrun.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About