Skip to content

Commit

Permalink
fix full-width characters issue (magmax/python-inquirer#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakkyoi committed Aug 10, 2024
1 parent b218c1e commit 75e8db1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions readchar/_win_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 75e8db1

Please sign in to comment.