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?
In reply to Re^2: Unicode input for Win32::Console
by Sue D. Nymme
in thread Unicode input for Win32::Console
by Sue D. Nymme
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |