From 75e8db1beea9ea9be3dda708c4aaa3ad44763c05 Mon Sep 17 00:00:00 2001 From: sakkyoi <22865542+sakkyoi@users.noreply.github.com> Date: Sat, 10 Aug 2024 14:27:27 +0800 Subject: [PATCH] fix full-width characters issue (https://github.com/magmax/python-inquirer/issues/432) --- readchar/_win_read.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readchar/_win_read.py b/readchar/_win_read.py index c3c51c7..d91db04 100644 --- a/readchar/_win_read.py +++ b/readchar/_win_read.py @@ -7,8 +7,8 @@ def readchar() -> str: """Reads a single character from the input stream. Blocks until a character is available.""" - # manual byte decoding because some bytes in windows are not utf-8 encodable. - return chr(int.from_bytes(msvcrt.getch(), "big")) + # read a single wide character from the input. + return msvcrt.getwch() def readkey() -> str: @@ -21,7 +21,7 @@ def readkey() -> str: raise KeyboardInterrupt # if it is a normal character: - if ch not in "\x00\xe0": + if ch not in "\x00\xc3\xa0": return ch # if it is a scpeal key, read second half: