C1 control characters break SetConsoleTitleW API #14088

Closed
opened 2026-01-31 04:00:35 +00:00 by claunia · 3 comments
Owner

Originally created by @alabuzhev on GitHub (Jun 2, 2021).

Windows Terminal version (or Windows build number)

1.9.1445.0

Other Software

No response

Steps to reproduce

  • Compile and run the following code:
#include <windows.h>

int main()
{
	if (!SetConsoleTitleW(L"\x80 Spanish Inquisition"))
		return 1;

	MessageBox(0, "I didn't expect that", 0, 0);
}
  • Look at the screen and listen.

Expected Behavior

The title is set.

Actual Behavior

  • Terminal beeps and prints the string on the screen. MSDN doesn't mention any such visual or sound effects.
  • The console title is not set, yet the function returns TRUE.

This is true for other C1 characters as well, not only 0x80.

P.S. The example is not synthetic: these characters can appear in directory and file names and applications can display the current path, the name of the opened file etc. in the console title.

Originally created by @alabuzhev on GitHub (Jun 2, 2021). ### Windows Terminal version (or Windows build number) 1.9.1445.0 ### Other Software _No response_ ### Steps to reproduce - Compile and run the following code: ```C++ #include <windows.h> int main() { if (!SetConsoleTitleW(L"\x80 Spanish Inquisition")) return 1; MessageBox(0, "I didn't expect that", 0, 0); } ``` - Look at the screen and listen. ### Expected Behavior The title is set. ### Actual Behavior - Terminal *beeps* and prints the string *on the screen*. [MSDN](https://docs.microsoft.com/en-us/windows/console/setconsoletitle) doesn't mention any such visual or sound effects. - The console title is not set, yet the function returns TRUE. This is true for other C1 characters as well, not only 0x80. P.S. The example is not synthetic: these characters can appear in directory and file names and applications can display the current path, the name of the opened file etc. in the console title.
Author
Owner

@j4james commented on GitHub (Jun 2, 2021):

I can't reproduce this in conhost - even a current build of OpenConsole - so I think this one is actually just a conpty issue. It looks like we sanitize the string before passing it through, but only strip out C0 controls and not C1 controls. See here:
b3775bc2b0/src/host/getset.cpp (L1929-L1945)

@j4james commented on GitHub (Jun 2, 2021): I can't reproduce this in conhost - even a current build of OpenConsole - so I _think_ this one is actually just a conpty issue. It looks like we sanitize the string before passing it through, but only strip out C0 controls and not C1 controls. See here: https://github.com/microsoft/terminal/blob/b3775bc2b0b46f9bca873594d47a739223211f21/src/host/getset.cpp#L1929-L1945
Author
Owner

@ghost commented on GitHub (Aug 31, 2021):

:tada:This issue was addressed in #10847, which has now been successfully released as Windows Terminal Preview v1.10.2383.0.🎉

Handy links:

@ghost commented on GitHub (Aug 31, 2021): :tada:This issue was addressed in #10847, which has now been successfully released as `Windows Terminal Preview v1.10.2383.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.10.2383.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

@ghost commented on GitHub (Aug 31, 2021):

:tada:This issue was addressed in #10847, which has now been successfully released as Windows Terminal Preview v1.11.2421.0.🎉

Handy links:

@ghost commented on GitHub (Aug 31, 2021): :tada:This issue was addressed in #10847, which has now been successfully released as `Windows Terminal Preview v1.11.2421.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.11.2421.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14088