I'm experiencing problems with the getch()
function of the curses
library.
Suppose we have the following program:
import curses
def main(stdscr):
while 1:
c = stdscr.getch()
stdscr.addstr(chr(c) + ": " + str(c) + "\n")
curses.wrapper(main)
Let's run this, and enter the following characters: a
, <backspace>
, œ
Then the output is:
a: 97
ć: 263
Å: 197
As you see, the a
character is taken correctly.
However, the others are not. I just want to get the backspace '\b'
and the unicode character œ
, but we get something else.
Why does getch()
behave this way, and how can I get the desired behaviour?
EDIT:
Let me emphasize that's it's not an issue with printing the characters, but with reading the characters. Namely, running stdscr.addstr('œ')
indeed prints œ
.