Some multibyte chars, e.g. 'α', cannot be read by ReadFile() under codepage 932 (Japanese). #10566

Open
opened 2026-01-31 02:24:46 +00:00 by claunia · 0 comments
Owner

Originally created by @tyan0 on GitHub (Sep 10, 2020).

Originally assigned to: @lhecker on GitHub.

Environment

Windows build number: Microsoft Windows [Version 10.0.18363.1082]
Windows Terminal version (if applicable): 1.2.2381.0

Steps to reproduce

  1. Compile the code below.
/* test-prog.c */
#include <windows.h>
#include <stdio.h>

int main()
{
        unsigned char buf[256];
        DWORD len;
        int i;
        ReadFile(GetStdHandle(STD_INPUT_HANDLE), buf, sizeof(buf), &len, NULL);
        for (i=0; i<len; i++) printf("%02x ", buf[i]);
        printf("\n");
        return 0;
}
  1. Open Windows Terminal with cmd.exe or powershell.exe.
  2. Run chcp 932.
  3. Run the test-prog above.
  4. Enter 'α' + [enter key].

Expected behavior

If the test-prog above is executed in command prompt, the multibyte char 'α' can be read correctly as follows.

C:\Test>test-prog
α
83 bf 0d 0a

Actual behavior

If the test-prog above is executed in Windows Terminal, the multibyte char 'α' cannot be read correctly as follows.

C:\Test>test-prog
α
00 0d 0a

This also happens with getchar(), getwchar(), gets(), ReadConsoleA(), etc.
As far as I tested, only ReadConsoleW() can read 'α' correctly.

Most of Japanese multibyte chars can be read correctly with the code above as follows

C:\Test>test-prog
あ
82 a0 0d 0a

even in Windows Terminal.

Supplement

Similar happens under CP936 (Simplified Chinese) and CP949 (Korean).

Originally created by @tyan0 on GitHub (Sep 10, 2020). Originally assigned to: @lhecker on GitHub. <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: Microsoft Windows [Version 10.0.18363.1082] Windows Terminal version (if applicable): 1.2.2381.0 ``` # Steps to reproduce <!-- A description of how to trigger this bug. --> 1) Compile the code below. ``` /* test-prog.c */ #include <windows.h> #include <stdio.h> int main() { unsigned char buf[256]; DWORD len; int i; ReadFile(GetStdHandle(STD_INPUT_HANDLE), buf, sizeof(buf), &len, NULL); for (i=0; i<len; i++) printf("%02x ", buf[i]); printf("\n"); return 0; } ``` 2) Open Windows Terminal with cmd.exe or powershell.exe. 3) Run chcp 932. 4) Run the test-prog above. 5) Enter 'α' + [enter key]. # Expected behavior <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> If the test-prog above is executed in command prompt, the multibyte char 'α' can be read correctly as follows. ``` C:\Test>test-prog α 83 bf 0d 0a ``` # Actual behavior <!-- What's actually happening? --> If the test-prog above is executed in Windows Terminal, the multibyte char 'α' cannot be read correctly as follows. ``` C:\Test>test-prog α 00 0d 0a ``` This also happens with getchar(), getwchar(), gets(), ReadConsoleA(), etc. As far as I tested, only ReadConsoleW() can read 'α' correctly. Most of Japanese multibyte chars can be read correctly with the code above as follows ``` C:\Test>test-prog あ 82 a0 0d 0a ``` even in Windows Terminal. # Supplement Similar happens under CP936 (Simplified Chinese) and CP949 (Korean).
claunia added the Issue-BugIn-PRArea-InputNeeds-Tag-FixProduct-TerminalPriority-2 labels 2026-01-31 02:24:47 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10566