in reply to Re: Unicode input for Win32::Console
in thread Unicode input for Win32::Console
Hi BrowserUK. Thanks for your reply. I tried your suggestion. Here is a new test program:
use Win32::Console; my $wc = Win32::Console->new(STD_INPUT_HANDLE); $wc->InputCP(65001); say 'Paste stuff now.'; Char: while (1) { my $char = $wc->InputChar(1); if (!defined $char) { say 'Read (undef)'; next Char; } # "pretty" character, for display my $pch = $char =~ /[[:^print:]]/? '?' : $char; # Deconstruct the character my @c = unpack 'C*', $char; say "Read: '$pch' = ", join ' - ', map sprintf('%02X',$_), @c; last if $char eq "\n"; }
It didn't work. InputChar returns undef when I paste a unicode character. Here's the output of the program when I pasted "# “dog’s” leg":
Read: '#' = 23 Read: ' ' = 20 Read (undef) Read: 'd' = 64 Read: 'o' = 6F Read: 'g' = 67 Read (undef) Read: 's' = 73 Read (undef) Read: ' ' = 20 Read: 'l' = 6C Read: 'e' = 65 Read: 'g' = 67 Read: '?' = 0D Read: '?' = 0A
The doco for InputChar says that it returns undef "on errors". But the module doesn't provide an interface to the Windows Console LastError function, so I can't see how to tell what error occurred.
Any suggestions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Unicode input for Win32::Console
by BrowserUk (Patriarch) on Oct 25, 2011 at 17:59 UTC | |
by Sue D. Nymme (Monk) on Oct 25, 2011 at 19:02 UTC | |
by BrowserUk (Patriarch) on Oct 25, 2011 at 20:40 UTC |