Skip to content

Title-case a word that starts with a ligature or "ʼn" [patch] - #137

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/133-ligature-word-start
Oct 30, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/133-ligature-word-start

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #133

What changed

TextInfo.ToTitleCase uses the simple case mapping. That mapping leaves the Latin ligatures U+FB00–U+FB06 (ff fi fl ffi ffl ſt st) and ʼn (U+0149) lowercase. A word that started with one of them stayed lowercase, so PascalCase and camelCase lost the boundary before it. For example, "the first" and "thefirst" both became "Thefirst".

ToTitleCase now calls a new TitleCaseWordStartsWithNoSimpleTitlecase step right after TitleCaseKeepingTypographicApostrophes. The step applies the full title case from SpecialCasing.txt to those letters when they start a word: fi → Fi, fl → Fl, ffi → Ffi, st → St, ʼn → ʼN, and so on. It runs as its own pass because the mapping changes the string's length. This is the full-titlecase option the triage preferred over expanding ligatures up front, so a ligature inside a word ("office") is left as it is. A letter after a digit is not treated as a word start, which matches LowercaseLettersAfterDigits.

Results:

  • "the first": Title The First, Pascal TheFirst, and Pascal→snake the_first (two words, as ToSnakeCase gives).
  • "my file".ToCamelCase() is myFile. "myfile".ToCamelCase() stays myfile.
  • "The First".ToTitleCase() converts back to itself.

One thing to look at: "die ʼn boek" now title-cases to Die ʼN Boek, and Pascal→snake gives three words, as it should. The splitter still attaches the caseless ʼ to the word before it (dieʼ_n_boek). That is the existing caseless-letter rule, so the test only pins the word count. The Dž/Lj digraph case in #106 is not touched.

Tests

  • Added AWordStartingWithALigatureShouldBeTitleCased (7 rows, including a mid-word ligature guard), AWordStartingWithALigatureShouldKeepItsBoundaryInCamelCase and AWordStartingWithNApostropheShouldBeTitleCased.
  • With the source change stashed, 8 of the new cases fail. With the change, all 205 tests pass on net10.0.
  • dotnet build CaseConverter.sln succeeds for every target framework, netstandard2.0 included, with no warnings.

Generated by Claude Code

TextInfo.ToTitleCase uses the simple case mapping, which leaves the Latin
ligatures U+FB00-U+FB06 and "ʼn" lowercase. A word starting with one stayed
lowercase, so PascalCase and camelCase lost the boundary before it: "the
first" and "thefirst" both became "Thefirst", and "my file" camel-cased the same
as "myfile". ToTitleCase now applies the full title case from SpecialCasing.txt
to such a word-initial letter, so "the first" becomes "The First" and
"TheFirst". A ligature inside a word is left as it is.

Fixes #133

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5r5WL5w6Xw9zvRF9a
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants