summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorYO4 <ysno@ac.auone-net.jp>2022-03-16 10:28:35 +0900
committerGitHub <noreply@github.com>2022-03-16 10:28:35 +0900
commit5d90c6010999ac11d25822f13f0b29d377f81755 (patch)
tree2df7388e17002800df264b0df5c5e786ba01cff3 /win32
parent48f1e8c5d85043e6adb8e93c94532daa201d42e9 (diff)
Avoid console input behavior in windows 10 [Bug #18588]
When ANSI versions of PeekConsoleInput read multibyte charactor partially, subsequent ReadFile returns wrong data on newer Windows 10 versions (probably since Windows Terminal introduced). To avoid this, use Unicode version of of PeekConsoleInput/ReadConsole.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5634 Merged-By: nobu <nobu@ruby-lang.org>
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 832725a645..c202e65e92 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -3085,7 +3085,7 @@ is_console(SOCKET sock) /* DONT call this for SOCKET! */
INPUT_RECORD ir;
RUBY_CRITICAL {
- ret = (PeekConsoleInput((HANDLE)sock, &ir, 1, &n));
+ ret = (PeekConsoleInputW((HANDLE)sock, &ir, 1, &n));
}
return ret;
@@ -3100,13 +3100,13 @@ is_readable_console(SOCKET sock) /* call this for console only */
INPUT_RECORD ir;
RUBY_CRITICAL {
- if (PeekConsoleInput((HANDLE)sock, &ir, 1, &n) && n > 0) {
+ if (PeekConsoleInputW((HANDLE)sock, &ir, 1, &n) && n > 0) {
if (ir.EventType == KEY_EVENT && ir.Event.KeyEvent.bKeyDown &&
ir.Event.KeyEvent.uChar.AsciiChar) {
ret = 1;
}
else {
- ReadConsoleInput((HANDLE)sock, &ir, 1, &n);
+ ReadConsoleInputW((HANDLE)sock, &ir, 1, &n);
}
}
}