Repository navigation
Closed
Labels
Area-InputRelated to input processing (key presses, mouse, etc.)Related to input processing (key presses, mouse, etc.)Issue-BugIt either shouldn't be doing this or needs an investigation.It either shouldn't be doing this or needs an investigation.Needs-Tag-FixDoesn't match tag requirementsDoesn't match tag requirementsPriority-2A description (P2)A description (P2)Product-ConhostFor issues in the Console codebaseFor issues in the Console codebase
Milestone
Description
Windows Terminal version
1.11.3471.0 / 1.13.10395.0
Windows build number
10.0.19043.1526
Other Software
ruby.exe seems to be affected this issue.
https://bugs.ruby-lang.org/issues/18588
command prompt window also wrong.
Legacy Console mode enabled command prompt works fine.
Steps to reproduce
- use PeekConsoleInputA(h, &ir, 1, &n) like kbhit()
- Input MultiByteChar from console(type or paste)
- ReadFile(or ReadConsoleA)
- Got wrong string
test program(test.cpp)
#include <windows.h>
#include <stdio.h>
/* from ruby/win32/win32.c */
static int
is_readable_console(HANDLE h)
{
int ret = 0;
DWORD n = 0;
INPUT_RECORD ir;
if (PeekConsoleInputA(h, &ir, 1, &n) && n > 0) {
if (ir.EventType == KEY_EVENT && ir.Event.KeyEvent.bKeyDown &&
ir.Event.KeyEvent.uChar.AsciiChar) {
ret = 1;
}
else {
ReadConsoleInputA(h, &ir, 1, &n);
}
}
return ret;
}
int main()
{
HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE);
unsigned char s[64];
DWORD n;
while (1) {
if (is_readable_console(hInput)) break;
Sleep(100);
}
//ReadFile(hInput, s, 16, &n, NULL);
ReadConsoleA(hInput, s, 16, &n, NULL);
for (unsigned int i = 0; i < n; i++) printf("<%02x>", s[i]);
return(0);
}
Expected Behavior
run test.exe and input text, hit enter. hexadecimal codes are printed.
C:\src\vs\test\x64\Debug>chcp 932
現在のコード ページ: 932
C:\src\vs\test\x64\Debug>test.exe
a
<61><0d><0a>
C:\src\vs\readfile\x64\Debug>test.exe
あ
<82><a0><0d>
Actual Behavior
C:\src\vs\test\x64\Debug>chcp 932
現在のコード ページ: 932
C:\src\vs\test\x64\Debug>test.exe
a
<61><0d><0a>
C:\src\vs\readfile\x64\Debug>test.exe
あ
<a0><ff><82><a0><0d>
<a0><ff> is garbage.
Metadata
Metadata
Assignees
Labels
Area-InputRelated to input processing (key presses, mouse, etc.)Related to input processing (key presses, mouse, etc.)Issue-BugIt either shouldn't be doing this or needs an investigation.It either shouldn't be doing this or needs an investigation.Needs-Tag-FixDoesn't match tag requirementsDoesn't match tag requirementsPriority-2A description (P2)A description (P2)Product-ConhostFor issues in the Console codebaseFor issues in the Console codebase
Activity
lhecker commentedon Jul 27, 2023
Thanks for pointing this issue out SainoNamkho! It indeed seems to have been fixed in PR #14745. 🙂
YO4 BTW I believe your "expected behavior" is not quite correct. This seems better to me:
The output should always be terminated with
\r\nand not just\r. #14745 handles this correctly and terminates it properly with\r\n=<0d><0a>. 👍