Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conpty rendering of control characters in the buffer #16825

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/renderer/vt/paint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,25 @@ using namespace Microsoft::Console::Types;
_bufferLine.append(cluster.GetText());
totalWidth += cluster.GetColumns();
}

// If any of the values in the buffer are C0 or C1 controls, we need to
// convert them to printable codepoints, otherwise they'll end up being
// evaluated as control characters by the receiving terminal. We use the
// DOS 437 code page for the C0 controls and DEL, and just a `?` for the
// C1 controls, since that's what you would most likely have seen in the
// legacy v1 console with raster fonts.
const auto cchLine = _bufferLine.size();
std::for_each_n(_bufferLine.begin(), cchLine, [](auto& ch) {
static constexpr std::wstring_view C0Glyphs = L" ☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼";
if (ch < C0Glyphs.size())
{
ch = til::at(C0Glyphs, ch);
}
else if (ch >= L'\u007F' && ch < L'\u00A0')
{
ch = (ch == L'\u007F' ? L'⌂' : L'?');
}
});

const auto spaceIndex = _bufferLine.find_last_not_of(L' ');
const auto foundNonspace = spaceIndex != decltype(_bufferLine)::npos;
Expand Down
Loading