Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- When using Curses, I can't echo back a character I've read in using `getchar`.
- ```perl
- #!/usr/bin/perl
- use warnings;
- use strict;
- use utf8;
- use open qw( :std :encoding(UTF-8) );
- use Curses;
- sub setup {
- initscr();
- raw();
- keypad(1);
- noecho();
- }
- sub teardown {
- endwin();
- }
- {
- setup();
- printw("Press any key to echo it...");
- my ($ch, $key) = getchar();
- printw("\n");
- printw("Got: %s\n", $ch) if defined($ch);
- printw("Press any key to exit...");
- getchar();
- endwin();
- }
- ```
- Try pasting each of `q`, `è` and `д`. The character is correctly output for only the first and third of these:
- ```lang-none
- Press any key to echo it...
- Got: q
- Press any key to exit...
- ```
- ```lang-none
- Press any key to echo it...
- Got:
- Press any key to exit...
- ```
- ```lang-none
- Press any key to echo it...
- Got: д
- Press any key to exit...
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement