Thread Encoding, Umlaute, ... (19 answers)
Opened by roli at 2015-07-10 14:04

FIFO
 2015-07-13 13:34
#181558 #181558
User since
2005-06-01
469 Artikel
BenutzerIn

user image
Ich verstehe das Problem nicht so ganz. Wenn Dein Skript cp1252 (Windows-ANSI) kodiert ist und Deine Konsole (per chcp 1252) ebenfalls, kannst Du einfach losprinten ohne encode/decode.

Das Eurozeichen gibt es in cp437/850 nicht.

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
my $str = "Ä Ö Ü ß €\n";

system( "chcp 1252" );
print $str;

my $res_file = "erg_1252.txt";
open( my $fh, ">", $res_file )
    or die "Could not open file '$res_file'";

print $fh $str;
close $fh;


Wenn Du ein portables Skript erstellen willst, kannst Du über use utf8 nachdenken, in diesem Fall musst Du die Ausgabe entsprechend encoden, falls Du Stringliterale aus dem Sourcecode ausgibst.
Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"

View full thread Encoding, Umlaute, ...