1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/usr/bin/env perl use warnings; use strict; use 5.10.1; use Encode; use Term::ReadKey; use Encode::Locale; binmode STDOUT, 'encoding(console_out)'; binmode STDIN, 'encoding(console_in)'; ReadMode 'cbreak'; my $key = ReadKey(); say decode( 'console_out', $key ); # Windows: ö - Linux: � say $key; # Windows: "\x{0094}" does not map to cp850 at ...19. - Linux: ö # \x{0094} ReadMode 'restore';
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
#!/usr/bin/env perl use warnings; use strict; use 5.10.1; use Encode; use Term::ReadKey; use Encode::Locale; binmode STDOUT, ":encoding(console_out)"; binmode STDIN, ":encoding(console_in)"; say $Encode::Locale::ENCODING_LOCALE; say $Encode::Locale::ENCODING_LOCALE_FS; say $Encode::Locale::ENCODING_CONSOLE_OUT; say $Encode::Locale::ENCODING_CONSOLE_IN; say ""; ReadMode 'cbreak'; my $key = ReadKey(); say "|$key|"; $key = decode( 'console_out', $key ); say "|$key|"; ReadMode 'restore';
1
2
3
4
5
6
7
8
cp1252
cp1252
cp850
cp850
"\x{0094}" does not map to cp850 at ... line 21.
|\x{0094}|
|ö|
QuoteCode: (dl )$key = decode( 'console_out', $key );
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
#!/usr/bin/env perl use warnings; use strict; use 5.10.1; use Encode; use Term::ReadKey; use Encode::Locale; Encode::Locale::reinit('cp850'); # set to standard CP850 =Latin1 binmode STDOUT, ":encoding(console_out)"; binmode STDIN, ":encoding(console_in)"; say $Encode::Locale::ENCODING_LOCALE; say $Encode::Locale::ENCODING_LOCALE_FS; say $Encode::Locale::ENCODING_CONSOLE_OUT; say $Encode::Locale::ENCODING_CONSOLE_IN; say ""; ReadMode 'cbreak'; my $key = ReadKey(); say "|$key|"; $key = decode( 'console_out', $key ); say "|$key|"; ReadMode 'restore';
1 2 3
my $in = <STDIN>; chomp $in; say "[$in]"; # sieht in der Konsole so aus: |÷| statt |ö|
2014-07-07T12:22:50 KuerbisDa ist kein Term::readline! Wo?(...) das normale readline nicht mehr.
2014-07-07T12:22:50 KuerbisWenn ich das alles so befolge(...)
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 34 35 36
#!/usr/bin/env perl use warnings; use strict; use 5.10.1; use Encode; use Term::ReadKey; use Encode::Locale; Encode::Locale::reinit('cp850'); # set to standard CP850 =Latin1 binmode STDOUT, ":encoding(console_out)"; binmode STDIN, ":encoding(console_in)"; say $Encode::Locale::ENCODING_LOCALE; say $Encode::Locale::ENCODING_LOCALE_FS; say $Encode::Locale::ENCODING_CONSOLE_OUT; say $Encode::Locale::ENCODING_CONSOLE_IN; say ""; do { ReadMode 'cbreak'; my $key = ReadKey(); say "|$key|"; $key = decode( 'console_out', $key ); say "|$key|"; ReadMode 'restore'; }; do { my $in = <STDIN>; chomp $in; say "[$in]"; };
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
use strict; use 5.10.1; use Encode; use Term::ReadKey; use Encode::Locale; Encode::Locale::reinit('cp850'); binmode STDOUT, ":encoding(console_out)"; binmode STDIN, ":encoding(console_in)"; say $Encode::Locale::VERSION; say $Term::ReadKey::VERSION; say $Encode::Locale::ENCODING_LOCALE; say $Encode::Locale::ENCODING_LOCALE_FS; say $Encode::Locale::ENCODING_CONSOLE_OUT; say $Encode::Locale::ENCODING_CONSOLE_IN; say ""; ReadMode 'cbreak'; $| = 1; my $key = ReadKey(); say "|$key|"; ReadMode 'restore'; my $in = <STDIN>; chomp $in; say "[$in]";
2014-07-07T13:53:02 KuerbisKann ich unter XP SP2 nur einmal nachvollziehen.Win XP
Aktive Codepage: 1252.
Perl 5.18.2
(...)
So sieht die Ausgabe in der Windows Konsole aus:
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 34 35 36 37 38
#!/usr/bin/env perl use warnings; use strict; use 5.10.1; use Encode; use Term::ReadKey; use Encode::Locale; use Term::ReadLine; #Encode::Locale::reinit('cp850'); print `chcp` if $^O eq 'MSWin32'; binmode STDOUT, ":encoding(console_out)"; binmode STDIN, ":encoding(console_in)"; say $Encode::Locale::ENCODING_LOCALE; say $Encode::Locale::ENCODING_LOCALE_FS; say $Encode::Locale::ENCODING_CONSOLE_OUT; say $Encode::Locale::ENCODING_CONSOLE_IN; say ""; ReadMode 'cbreak'; $| = 1; print ': '; my $key = ReadKey(); $key = decode( 'console_in', $key ) if $^O eq 'MSWin32'; say "\nReadKey|$key|"; ReadMode 'restore'; say "========================="; print ': '; my $in = readline; chomp $in; say 'readline[' . $in . ']'; say "========================="; my $term = Term::ReadLine->new( 'Text' ); $term->ornaments( 0 ); my $con = $term->readline( ': ' ); $con = decode( 'console_in', $con ); say $term->ReadLine . "{$con}";