Thread Frage zu Windows, Encoding und Codepage (13 answers)
Opened by Kuerbis at 2018-11-25 08:28

Kuerbis
 2018-11-25 08:28
#189297 #189297
User since
2011-03-20
943 Artikel
BenutzerIn
[default_avatar]
Hallo,

ist es OK - in Bezug auf MSWin32 OS -, diesen Code mit dem zweiten zu ersetzten?

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env perl
use warnings;
use strict;
use Encode::Locale qw();
use Term::Choose::Constants qw( :screen );
use App::DBBrowser;

use if $^O eq 'MSWin32', 'Win32::Console::ANSI';
print "\e(U" if $^O eq 'MSWin32';

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

END { print SHOW_CURSOR }

print HIDE_CURSOR;

my $db_browser = App::DBBrowser->new();
$db_browser->run();

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
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env perl
use warnings;
use strict;
use Term::Choose::Constants qw( :screen );
use App::DBBrowser;

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 {
    print SHOW_CURSOR;
    if ( $^O eq "MSWin32" ) {
        Win32::Console::OutputCP( $old_out_codepage ) if $old_out_codepage;
    }
}

print HIDE_CURSOR;

my $db_browser = App::DBBrowser->new();
$db_browser->run();

View full thread Frage zu Windows, Encoding und Codepage