Skip to content

Fix #2561: Escape control characters in assertion error messages#2690

Draft
nohwnd wants to merge 1 commit intopester:mainfrom
nohwnd:fix-2561-escape-chars
Draft

Fix #2561: Escape control characters in assertion error messages#2690
nohwnd wants to merge 1 commit intopester:mainfrom
nohwnd:fix-2561-escape-chars

Conversation

@nohwnd
Copy link
Copy Markdown
Member

@nohwnd nohwnd commented Apr 3, 2026

Fix #2561

Format-String2 now escapes control characters as Unicode control pictures so they are visible in error messages. Characters like ESC (used in ANSI sequences) now display as their Unicode symbol instead of being invisible.

Copilot-generated fix.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Comment on lines +56 to +64
$Value = $Value `
-replace "`0", '␀' `
-replace "`a", '␇' `
-replace "`b", '␈' `
-replace "`t", '␉' `
-replace "`f", '␌' `
-replace "`r", '␍' `
-replace "`n", '␊' `
-replace "`e", '␛'
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels like we are re-constructing the same string so many times this way, we should have some similar code that does this by prepenting the code point with a bit that makes it visible. and does that via string builder and a loop. basically re-building the whole string just once.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

special chars are uncommon, so this should be as cheap as possible.

Format-String2 now escapes control characters as Unicode control pictures
so they are visible in error messages. Characters like ESC (used in ANSI
sequences) now display as their Unicode symbol instead of being invisible.

Copilot-generated fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nohwnd nohwnd force-pushed the fix-2561-escape-chars branch from af6075c to 1d213ef Compare April 3, 2026 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should-BeString: Doesn't handle escape character correctly in error message

1 participant