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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.