Thread Windows: InputChar mit mulit-byte Encoding
(4 answers)
Opened by Kuerbis at 2014-07-11 09:18
Hallo,
wie kann ich herausfinden, wie sich dieses Script mit bei einem multi-byte Encoding verhält? 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 #!perl use warnings; use strict; use 5.10.0; use utf8; use Encode; use Devel::Peek; use Encode::Locale; #Encode::Locale::reinit('utf-8'); binmode STDIN, ':encoding(console_in)'; binmode STDOUT, ':encoding(console_out)'; binmode STDERR, ':encoding(console_out)'; use Term::ReadKey; ReadMode 3; my $c = ReadKey; $c = decode( 'console_in', $c ); Dump $c; say "[$c]"; ReadMode 0; use Win32::Console; my $in = Win32::Console->new( STD_INPUT_HANDLE ); $in->Mode( ENABLE_PROCESSED_INPUT ); my $char = $in->InputChar(); $char = decode( 'console_in', $char ); Dump $char; say "{$char}"; |