Thread Encoding-Frage (1 answers)
Opened by Kuerbis at 2022-07-04 19:14

Kuerbis
 2022-07-04 19:14
#194396 #194396
User since
2011-03-20
938 Artikel
BenutzerIn
[default_avatar]
Hallo, noch eine Frage:

CPAN:App::DBBrowser beginnt ungefähr so:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env perl

binmode STDIN,  ':encoding(utf-8)';
binmode STDOUT, ':encoding(utf-8)';
binmode STDERR, ':encoding(utf-8)';

my $old_out_codepage;

BEGIN {
    if ( $^O eq "MSWin32" ) {
        require Win32::Console;
        require Win32::Console::ANSI;
        $old_out_codepage = Win32::Console::OutputCP();
        Win32::Console::OutputCP( 65001 );
        print "\e(U";
    }
}

END {
    if ( $^O eq "MSWin32" && $old_out_codepage ) {
        Win32::Console::OutputCP( $old_out_codepage );
    }
}


Wenn ich die hardcodierten binmodes mit

Code (perl): (dl )
1
2
3
4
5
use Encode::Locale;

binmode STDIN,  ':encoding(console_in)';
binmode STDOUT, ':encoding(console_out)';
binmode STDERR, ':encoding(console_out)';


ersetzte, sollte ich dann bei Win32 das Setzen der Konsole auf copdepage 65001

* weglessen
* vor die binmods schieben (falls das funktionert)
* lassen wie es jetzt ist und bei Win32 binmode auf 'utf-8' setzen?

View full thread Encoding-Frage