Martin Barth schreef:
> [use encoding]
> If I understand you right, following code should allways create a utf8
> encoded file.
No, "use encoding" is about the encoding of your script, not about file
IO.
<quote src="encoding">
encoding - allows you to write your script in non-ascii or non-utf8
</quote>
> Since my inputfile does only contain 7bit ascii data.
> and STDIN STDOUT and STDERR is changed to utf8.
>
> % perl -C7 -wpi -e 'use encoding "utf8"; s/"o/ö/' datei
In that case, your -C7 could be -C4 or -CE, because STDIN and STDOUT are
already handled by the "encoding" pragma, see again `perldoc encoding`.
But you missed the 8+16 (i+o). See `perldoc perlrun`.
The C<use encoding "utf8"> could be done through -M. But you don't need
"encoding".
So better write it as
perl -Cio -wpi -e 's/"o/\x{f6}/' datei
(or -CIOEio, which is -C31)
> % file datei
> datei: ISO-8859 text
Why not "ASCII text"? Are you sure there are no 8 bit values in there?
(Maybe you forgot to put the original file back, consider "-i.bak".)
> % hexdump -C datei
> 00000000 65 69 6e 65 20 74 65 73 74 20 64 61 74 65 69 0a
> |eine test datei.|
> 00000010 64 69 65 20 22 75 20 f6 20 0a
> |die "u . .|
>
> f6 = ö in lation1
> c3 b6 = ö in utf8
$ file datei
datei: ASCII text
$ hexdump -e '"%07_ad" 16/1 " %02X" "\n"'
-e '" " 16/1 " %-2_p" "\n\n"' datei
0000000 65 69 6E 20 74 65 73 74 20 64 61 74 65 69 0A 64
e i n t e s t d a t e i . d
0000016 69 65 20 22 75 20 22 6F 0A
i e " u " o .
$ perl -C31 -i.bak -wpe 's/"o/\x{f6}/g' datei
$ hexdump -e '"%07_ad" 16/1 " %02X" "\n"' \
-e '" " 16/1 " %-2_p" "\n\n"' datei
0000000 65 69 6E 20 74 65 73 74 20 64 61 74 65 69 0A 64
e i n t e s t d a t e i . d
0000016 69 65 20 22 75 20 C3 B6 0A
i e " u . . .
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/