[PR #16825] Fix conpty rendering of control characters in the buffer #31010

Open
opened 2026-01-31 09:44:32 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/16825

State: closed
Merged: Yes


Summary of the Pull Request

When using the legacy console APIs, it's possible to write arbitrary
codepoints into the buffer. If any of those codepoints are in the C0 or
C1 range, and the buffer contents are forwarded over conpty, they can
end up mistakenly interpreted as controls by the connected terminal.

This PR fixes that issue by converting any C0 and C1 codepoints in the
buffer into printable glyphs before forwarding them over conpty. I've
used the C0 glyphs from the DOS 437 codepage and just a ? for the C1
codepoints, since that's what you would typically have seen in the v1
console with a raster font.

References and Relevant Issues

Although this doesn't address the main problem in #16410, it should at
least fix the rendering issues they're seeing when running their app in
Windows Terminal.

Validation Steps Performed

I've confirmed that the test case in #4363 now looks the same in Windows
Terminal as it does in conhost, and I've tested the Windows version of
the terminal game Gorched, and confirmed that it now works correctly
in Window Terminal.

PR Checklist

**Original Pull Request:** https://github.com/microsoft/terminal/pull/16825 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request When using the legacy console APIs, it's possible to write arbitrary codepoints into the buffer. If any of those codepoints are in the C0 or C1 range, and the buffer contents are forwarded over conpty, they can end up mistakenly interpreted as controls by the connected terminal. This PR fixes that issue by converting any C0 and C1 codepoints in the buffer into printable glyphs before forwarding them over conpty. I've used the C0 glyphs from the DOS 437 codepage and just a `?` for the C1 codepoints, since that's what you would typically have seen in the v1 console with a raster font. ## References and Relevant Issues Although this doesn't address the main problem in #16410, it should at least fix the rendering issues they're seeing when running their app in Windows Terminal. ## Validation Steps Performed I've confirmed that the test case in #4363 now looks the same in Windows Terminal as it does in conhost, and I've tested the Windows version of the terminal game [Gorched], and confirmed that it now works correctly in Window Terminal. [Gorched]: https://github.com/zladovan/gorched ## PR Checklist - [x] Closes #4363 - [x] Closes #6265
claunia added the pull-request label 2026-01-31 09:44:32 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31010