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

FIFO
 2015-07-13 13:53
#181561 #181561
User since
2005-06-01
469 Artikel
BenutzerIn

user image
Wenn Du portabel sein willst/musst:

Sourcecode als UTF-8 abspeichern. Dann bei Ausgabe ggf. encode:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use utf8;    # Skript in UTF-8 kodiert

use Encode qw( encode );

my $str = "Ä Ö Ü ß €\n";

if ( $^O eq "MSWin32" ) {
    $str = encode( "cp1252", $str );
    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;


Editiert von FIFO: system() in Win32-Block verschoben
Last edited: 2015-07-13 13:57:33 +0200 (CEST)
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, ...