Thread Term::ReadKey::ReadKey Codierungsfrage (13 answers)
Opened by Kuerbis at 2014-07-06 21:09

Kuerbis
 2014-07-07 18:40
#176334 #176334
User since
2011-03-20
947 Artikel
BenutzerIn
[default_avatar]
Term::ReadKey wegzulassen hat nichts verändert (außer dass Readkey weg war).

Ich werde es mit einem bedingten decode für Windows versuchen:

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
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}";

View full thread Term::ReadKey::ReadKey Codierungsfrage