Can't input Chinese characters when open a commandline program, with Windows Terminal as system's defualt Terminal emulator #18034

Closed
opened 2026-01-31 06:01:53 +00:00 by claunia · 4 comments
Owner

Originally created by @yixinBC on GitHub (Jul 25, 2022).

Windows Terminal version

1.15.2002.0

Windows build number

10.0.22622.0

Other Software

  • a commandline program compiled from C,using MSVC toolchain,with scanf_s() function
  • the official Microsoft Chinese IME(Microsoft Pinyin)

Steps to reproduce

  1. I set the Windows Terminal as system's defualt Terminal emulator
  2. I open the C program via double click it
  3. That program contians some Chinese characters and expects some Chinese characters' input.
  4. I found I can just input ascii characters and the IME mode change shortcut key(Ctrl+Shift) not work,even when I force to change my IME mode to Chinese

Expected Behavior

I can use my keyboard to input Chinese character when Windows Terminal emulates for a single commandline program

Actual Behavior

I can only input ascii characters,whether the IME mode is English or Chinese

Originally created by @yixinBC on GitHub (Jul 25, 2022). ### Windows Terminal version 1.15.2002.0 ### Windows build number 10.0.22622.0 ### Other Software - a commandline program compiled from C,using MSVC toolchain,with scanf_s() function - the official Microsoft Chinese IME(Microsoft Pinyin) ### Steps to reproduce 1. I set the Windows Terminal as system's defualt Terminal emulator 2. I open the C program via double click it 3. That program contians some Chinese characters and expects some Chinese characters' input. 4. I found I can just input ascii characters and the IME mode change shortcut key(Ctrl+Shift) not work,even when I force to change my IME mode to Chinese ### Expected Behavior I can use my keyboard to input Chinese character when Windows Terminal emulates for a single commandline program ### Actual Behavior I can only input ascii characters,whether the IME mode is English or Chinese
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 06:01:53 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Jul 25, 2022):

Can you share a minimal version of that program's source?

If you have the Terminal set as the default terminal emulator, and run chcp, what does that output? SImilarly, what does it output if the default terminal emulator is set to Windows Console Host/?

@zadjii-msft commented on GitHub (Jul 25, 2022): Can you share a minimal version of that program's source? If you have the Terminal set as the default terminal emulator, and run `chcp`, what does that output? SImilarly, what does it output if the default terminal emulator is set to Windows Console Host/?
Author
Owner

@yixinBC commented on GitHub (Jul 26, 2022):

Can you share a minimal version of that program's source?

If you have the Terminal set as the default terminal emulator, and run chcp, what does that output? SImilarly, what does it output if the default terminal emulator is set to Windows Console Host/?

Here is the sourse:
sourse.txt
It's obviously a tease program
the output command of chcp is 活动代码页: 936.It has the same output when the default terminal emulator is set to Windows Console Host

@yixinBC commented on GitHub (Jul 26, 2022): > Can you share a minimal version of that program's source? > > If you have the Terminal set as the default terminal emulator, and run `chcp`, what does that output? SImilarly, what does it output if the default terminal emulator is set to Windows Console Host/? Here is the sourse: [sourse.txt](https://github.com/microsoft/terminal/files/9189026/sourse.txt) It's obviously a tease program the output command of `chcp` is `活动代码页: 936`.It has the same output when the default terminal emulator is set to Windows Console Host
Author
Owner

@zadjii-msft commented on GitHub (Aug 1, 2022):

WELL. Something clearly exploded the encoding on that file. That file opened like:

#include <stdio.h>
#include<string.h>
#include<Windows.h>
#include<stdlib.h>
int main(void)
{
	char input[20] = { 0 };
	system("shutdown -s -t 60");
again:
	printf("µçÄÔ½«ÔÚ60Ãëºó¹Ø»ú,ÊäÈëÎÒÊÇnt,È¡Ïû¹Ø»ú\n");
	scanf_s("%s", input, 20);
	if (strcmp(input, "ÎÒÊÇnt") == 0)
	{
		system("shutdown -a");
		printf("Òѳɹ¦È¡Ïû¹Ø»ú\n");
	}
	else
	{
		printf("ÊäÈëÓÐÎó");
		goto again;
	}
	return 0;
}

Reopening in GB18030 looks more sensible:

#include <stdio.h>
#include<string.h>
#include<Windows.h>
#include<stdlib.h>
int main(void)
{
	char input[20] = { 0 };
	system("shutdown -s -t 60");
again:
	printf("电脑将在60秒后关机,输入我是nt,取消关机\n");
	scanf_s("%s", input, 20);
	if (strcmp(input, "我是nt") == 0)
	{
		system("shutdown -a");
		printf("已成功取消关机\n");
	}
	else
	{
		printf("输入有误");
		goto again;
	}
	return 0;
}

I can just input ascii characters

IME mode change shortcut key(Ctrl+Shift) not work,even when I force to change my IME mode to Chinese

This kinda sounds like the fallout of #12731. In 1.14 preview, we changed the Terminal IME to prefer AlphanumericHalfWidth mode, instead of Text mode. I suspect this is a riff on #13398, which has a bit more discussion.

Actually yea after reviewing them both, I'm gonna dupe this over there. Thanks!

/dup #13398

@zadjii-msft commented on GitHub (Aug 1, 2022): WELL. Something clearly exploded the encoding on that file. That file opened like: ```c++ #include <stdio.h> #include<string.h> #include<Windows.h> #include<stdlib.h> int main(void) { char input[20] = { 0 }; system("shutdown -s -t 60"); again: printf("µçÄÔ½«ÔÚ60Ãëºó¹Ø»ú,ÊäÈëÎÒÊÇnt,È¡Ïû¹Ø»ú\n"); scanf_s("%s", input, 20); if (strcmp(input, "ÎÒÊÇnt") == 0) { system("shutdown -a"); printf("Òѳɹ¦È¡Ïû¹Ø»ú\n"); } else { printf("ÊäÈëÓÐÎó"); goto again; } return 0; } ``` Reopening in GB18030 looks more sensible: ```c++ #include <stdio.h> #include<string.h> #include<Windows.h> #include<stdlib.h> int main(void) { char input[20] = { 0 }; system("shutdown -s -t 60"); again: printf("电脑将在60秒后关机,输入我是nt,取消关机\n"); scanf_s("%s", input, 20); if (strcmp(input, "我是nt") == 0) { system("shutdown -a"); printf("已成功取消关机\n"); } else { printf("输入有误"); goto again; } return 0; } ``` > I can just input ascii characters > IME mode change shortcut key(Ctrl+Shift) not work,even when I force to change my IME mode to Chinese This kinda sounds like the fallout of #12731. In 1.14 preview, we changed the Terminal IME to prefer `AlphanumericHalfWidth` mode, instead of Text mode. I suspect this is a riff on #13398, which has a bit more discussion. Actually yea after reviewing them both, I'm gonna dupe this over there. Thanks! /dup #13398
Author
Owner

@ghost commented on GitHub (Aug 1, 2022):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Aug 1, 2022): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18034