fix: keep surrogate pairs whole when NominalWordWrap hard-breaks a word [patch] - #147
Open
matt-edmondson wants to merge 2 commits into
Open
matt-edmondson wants to merge 2 commits into
matt-edmondson wants to merge 2 commits into
Conversation
…rd [patch] The hard-break loop cut every maxCharsPerLine UTF-16 code units, so a cut could land between the halves of a non-BMP character and leave both lines with a lone surrogate. The cut now steps back one code unit when it would split a pair, and at a width of one lets the pair overhang instead. Fixes #142 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VwgZGoivWyqL4pWDsenTPm
…STEST0068) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VwgZGoivWyqL4pWDsenTPm
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



When
NominalWordWraphard-breaks a word, it no longer cuts between the two halves of a surrogate pair. Before this,"😀😀😀".NominalWordWrap(3f, 1f)gave"😀\uD83D"and"\uDE00😀". Both lines were invalid UTF-16, rendered as replacement glyphs, and made a strict encoder throw.Mechanism
<returns>doc now mentions this, next to the existing soft-hyphen overhang note.This is the minimal fix the issue suggests. It keeps surrogate pairs together but not combining sequences or ZWJ emoji, which breaking on
StringInfotext elements would also keep together.Tests
"😀😀😀"and"ab😀cd"at width 3), and"a😀b"at width 1 for the overhang case.dotnet buildis clean on every target framework.Fixes #142
🤖 Generated with Claude Code
https://claude.ai/code/session_01VwgZGoivWyqL4pWDsenTPm
Generated by Claude Code