Keep the letter after a typographic apostrophe lowercase in ToTitleCase [patch] - #91
Merged
Merged
Conversation
…se [patch] TextInfo.ToTitleCase only special-cases the ASCII apostrophe, so an in-word U+2019 was treated as a word separator: "don’t stop" became "Don’T Stop". Swap each in-word U+2019 for ' before the call and restore it by index after. Fixes #89 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N3tMVtLPuNwsQF7rUEBTMQ
|
This was referenced Sep 28, 2026
This was referenced Sep 28, 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 #89
What was wrong
TextInfo.ToTitleCasekeeps the letter after an ASCII'lowercase, but treats U+2019 (the typographic apostrophe) as a word separator. So"don’t stop".ToTitleCase()gaveDon’T Stop, although the rest of the library (IsApostropheWithinWord,IsWordCharacter) already treats U+2019 the same as'.Change
ToTitleCasenow calls a newTitleCaseKeepingTypographicApostropheshelper. It swaps each in-word U+2019 (one with a letter on each side, as decided byIsApostropheWithinWord) for', runsTextInfo.ToTitleCase, and then puts U+2019 back at the same indices.TextInfo.ToTitleCasedoes not change the string's length, so restoring by index is safe. A U+2019 used as a quote mark, and so not inside a word, is left alone and still separates words.Tests
ToTitleCaseShouldKeepATypographicApostropheInsideItsWord:"don’t stop"→Don’t Stop"it’s fine"→It’s Fine"’quoted’ word"→’Quoted’ Word(a quote-mark U+2019 still separates words)With
CaseConverter.csreverted, the first two rows fail. With the change, all 68 tests pass on net10.0, and the solution builds for every target with 0 warnings.🤖 Generated with Claude Code
https://claude.ai/code/session_01N3tMVtLPuNwsQF7rUEBTMQ
Generated by Claude Code