Apparently, ReadConsoleInputA() does mistaken sign extension to 16 bits,

rather than writing only the bottom 8 bits of the decoded key to the
event structure. PDCurses, in turn, was reading the whole 16 bits even
in narrow mode, resulting in corrupted "high-bit" characters in wincon.
Potentially an issue since 3.0 (assuming ReadConsoleInputA() always did
this?), but seemingly unreported (?) until now. Reported by Simon
Sobisch.
This commit is contained in:
William McBrine
2021-06-19 12:12:19 -04:00
parent 793556fff3
commit e28e705d17

View File

@@ -331,7 +331,12 @@ static int _get_key_count(void)
static int _process_key_event(void)
{
int key = (unsigned short)KEV.uChar.UnicodeChar;
int key =
#ifdef PDC_WIDE
KEV.uChar.UnicodeChar;
#else
KEV.uChar.AsciiChar;
#endif
WORD vk = KEV.wVirtualKeyCode;
DWORD state = KEV.dwControlKeyState;