Some characters are not displayed in the terminal #22197

Closed
opened 2026-01-31 08:06:14 +00:00 by claunia · 5 comments
Owner

Originally created by @nukoseer on GitHub (Aug 31, 2024).

Windows Terminal version

1.20.11781.0

Windows build number

10.0.19045.0

Other Software

No response

Steps to reproduce

Try to print 0x1F(▲) and 0x1E(▼) characters (in codepage 437) to the terminal. I can print 0xDA(┌) without any problem for example.

Expected Behavior

Characters should be displayed correctly.

This is an example program running directly in CMD:
https://github.com/user-attachments/assets/956b710e-2dbd-47c1-a321-d9f465072138

Actual Behavior

0x1F(▲) and 0x1E(▼) are not displayed but for example 0xDA(┌) is displayed.

Same program running in terminal:
https://github.com/user-attachments/assets/db0a348e-39d4-44b9-a03f-be014f7d8a0d

Originally created by @nukoseer on GitHub (Aug 31, 2024). ### Windows Terminal version 1.20.11781.0 ### Windows build number 10.0.19045.0 ### Other Software _No response_ ### Steps to reproduce Try to print `0x1F`(▲) and `0x1E`(▼) characters (in codepage 437) to the terminal. I can print `0xDA`(┌) without any problem for example. ### Expected Behavior Characters should be displayed correctly. This is an example program running directly in CMD: https://github.com/user-attachments/assets/956b710e-2dbd-47c1-a321-d9f465072138 ### Actual Behavior `0x1F`(▲) and `0x1E`(▼) are not displayed but for example `0xDA`(┌) is displayed. Same program running in terminal: https://github.com/user-attachments/assets/db0a348e-39d4-44b9-a03f-be014f7d8a0d
claunia added the Needs-TriageIssue-Bug labels 2026-01-31 08:06:14 +00:00
Author
Owner

@j4james commented on GitHub (Aug 31, 2024):

Windows Terminal has VT mode enabled by default, while the old conhost does not. When in VT mode, those codepoints are treated as control characters, so they aren't displayed. If you want the old behavior in Windows Terminal you'll need to disable that mode in your application with something like this:

HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode;
GetConsoleMode(handle, &mode);
mode &= ~ENABLE_VIRTUAL_TERMINAL_PROCESSING;
SetConsoleMode(handle, mode);
@j4james commented on GitHub (Aug 31, 2024): Windows Terminal has VT mode enabled by default, while the old conhost does not. When in VT mode, those codepoints are treated as control characters, so they aren't displayed. If you want the old behavior in Windows Terminal you'll need to disable that mode in your application with something like this: ```cpp HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); DWORD mode; GetConsoleMode(handle, &mode); mode &= ~ENABLE_VIRTUAL_TERMINAL_PROCESSING; SetConsoleMode(handle, mode); ```
Author
Owner

@nukoseer commented on GitHub (Aug 31, 2024):

I use VT sequences in my program but also want to be able to print ▲ and ▼ characters. Probably I should change how I output characters to the console then. As far as I see If I use unicode points to print them there are no problems.

No problem in this case:

HANDLE h_console = GetStdHandle(STD_OUTPUT_HANDLE);

DWORD mode = 0;
GetConsoleMode(h_console, &mode);
SetConsoleMode(h_console, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);

wchar_t unicode_char = L'\u25B2';
DWORD chars_written;
WriteConsoleW(h_console, &unicode_char, 1, &chars_written, NULL);

But now I print like this:

HANDLE h_console = GetStdHandle(STD_OUTPUT_HANDLE);

DWORD mode = 0;
GetConsoleMode(h_console, &mode);
SetConsoleMode(h_console, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);

char unicode_char = 0x1E;
DWORD chars_written;
WriteConsole(h_console, &unicode_char, 1, &chars_written, NULL);

This is not a bug then. I just did not know the effect of ENABLE_VIRTUAL_TERMINAL_PROCESSING.

@nukoseer commented on GitHub (Aug 31, 2024): I use VT sequences in my program but also want to be able to print ▲ and ▼ characters. Probably I should change how I output characters to the console then. As far as I see If I use unicode points to print them there are no problems. No problem in this case: ``` HANDLE h_console = GetStdHandle(STD_OUTPUT_HANDLE); DWORD mode = 0; GetConsoleMode(h_console, &mode); SetConsoleMode(h_console, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING); wchar_t unicode_char = L'\u25B2'; DWORD chars_written; WriteConsoleW(h_console, &unicode_char, 1, &chars_written, NULL); ``` But now I print like this: ``` HANDLE h_console = GetStdHandle(STD_OUTPUT_HANDLE); DWORD mode = 0; GetConsoleMode(h_console, &mode); SetConsoleMode(h_console, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING); char unicode_char = 0x1E; DWORD chars_written; WriteConsole(h_console, &unicode_char, 1, &chars_written, NULL); ``` This is not a bug then. I just did not know the effect of `ENABLE_VIRTUAL_TERMINAL_PROCESSING`.
Author
Owner

@nukoseer commented on GitHub (Sep 3, 2024):

One more question to understand the behavior. If I enable the VT mode at the beginning of my program, cmd can print those characters without problem. It looks like for cmd it doesn't matter if it is enabled or not, the behavior is same. But for terminal this is not the case. Is this also normal?

@nukoseer commented on GitHub (Sep 3, 2024): One more question to understand the behavior. If I enable the VT mode at the beginning of my program, cmd can print those characters without problem. It looks like for cmd it doesn't matter if it is enabled or not, the behavior is same. But for terminal this is not the case. Is this also normal?
Author
Owner

@j4james commented on GitHub (Sep 3, 2024):

Sorry, I should have mentioned that. The original VT implementation didn't parse all of the control characters, so it was initially possible to print some subset of them with VT mode enabled (that would also have been the case for older versions of Windows Terminal). However, that was fixed over a year ago. It's just that the Windows 10 console isn't updated anymore, so that's why you can still print them there. I suspect they won't be printable in the Windows 11 console, at least not long term.

@j4james commented on GitHub (Sep 3, 2024): Sorry, I should have mentioned that. The original VT implementation didn't parse all of the control characters, so it _was_ initially possible to print some subset of them with VT mode enabled (that would also have been the case for older versions of Windows Terminal). However, that was fixed over a year ago. It's just that the Windows 10 console isn't updated anymore, so that's why you can still print them there. I suspect they won't be printable in the Windows 11 console, at least not long term.
Author
Owner

@lhecker commented on GitHub (Sep 3, 2024):

I definitely recommend using UTF-8 (or UTF-16) for all output. There are performance benefits (UTF-8 <> UTF-16 translation is a lot faster than between code-pages and UTF-16), but also correctness benefits, because no shimming with modern Unicode expectations is required (e.g. writing U+25B2 with UTF-8 yields U+25B2 when reading with UTF-16 and vice versa; Unicode input as seen by the user is read losslessly by the application, etc.).

Your issue has been resolved, right? I'll be closing the issue for now then. Please continue writing here if you'd like or reopen it if you find any other (related) issues.

@lhecker commented on GitHub (Sep 3, 2024): I definitely recommend using UTF-8 (or UTF-16) for all output. There are performance benefits (UTF-8 <> UTF-16 translation is a lot faster than between code-pages and UTF-16), but also correctness benefits, because no shimming with modern Unicode expectations is required (e.g. writing U+25B2 with UTF-8 yields U+25B2 when reading with UTF-16 and vice versa; Unicode input as seen by the user is read losslessly by the application, etc.). Your issue has been resolved, right? I'll be closing the issue for now then. Please continue writing here if you'd like or reopen it if you find any other (related) issues.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22197