Repository navigation
Keep a zero-width joiner, non-joiner or soft hyphen inside its word [patch] - #147
Merged
Merged
Conversation
…patch]
Every character that is not a letter, mark or digit became a word break, which
included format characters that sit inside a word: the ZWNJ of Persian
"میخواهم", the ZWJ of a Devanagari conjunct, and a soft hyphen. One word split
into two ("cooperate" gave snake "co_operate"), and TextInfo.ToTitleCase
capitalised the letter after them ("CoOperate").
A single-unit format character with a letter on each side (the letter before
may carry combining marks) is now treated like a combining mark, and is swapped
for an apostrophe around TextInfo.ToTitleCase the way an in-word U+2019 already
is. The zero-width space still separates words.
Fixes #145
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW1neHQijj1MhQeHXuM
|
This was referenced Oct 30, 2026
This was referenced Nov 11, 2026
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.



Fixes #145
What changed
IsFormatCharacterWithinWord: a single-UTF-16-unitUnicodeCategory.Formatcharacter with a letter on each side. The letter before it may carry combining marks, as the virama ofक्षdoes. U+200B ZERO WIDTH SPACE is excluded because it marks a word break.IsCombiningMarknow means "part of the letter before it", covering marks (nowIsMark) and these format characters. That one change carries the fix throughReplaceNonAlphaNumericWithSpace,IsWordBoundary,IsWordCharacter, and the skip-over/skip-back helpers.TitleCaseKeepingTypographicApostrophesswaps an in-word format character for'aroundTextInfo.ToTitleCaseand puts it back afterwards, the same way it already handles an in-word U+2019. This stops"cooperate"becoming"CoOperate".میخواهم(ZWNJ)می_خواهم, Pascal drops the ZWNJक्ष(ZWJ)क्_षcooperateCoOperate, snakeco_operateCooperate/cooperateThe issue lists stripping the soft hyphen from joined outputs as optional. This PR doesn't do it: the character is kept, so every converter preserves what the input contained.
Tests
AFormatCharacterInsideAWordShouldNotSplitItcovers each of the three inputs in every converter.AFormatCharacterInsideAWordShouldStayInThatWordcovers the same words next to another word.AFormatCharacterNotBetweenLettersShouldStillSeparateWordskeeps U+200B, a leading or trailing soft hyphen, and a ZWNJ between spaces acting as separators.This branch is cut from
mainindependently of #146 (#144). The two touch different functions.Generated by Claude Code