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

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

Thread Next
From:
Father Chrysostomos via RT
Date:
September 26, 2010 13:46
Subject:
[perl #43248] utf8 encoding and the -i switch
Message ID:
rt-3.6.HEAD-5116-1285534003-968.43248-15-0@perl.org
On Tue Jun 19 00:14:20 2007, martin@senfdax.de wrote:
> This is a bug report for perl from martin@senfdax.de,
> 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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About