Repository navigation
Treat a titlecase digraph as a capital when splitting words [patch] - #158
Merged
Merged
Conversation
Dž, Lj, Nj and Dz are in category Lt, so char.IsUpper is false for them and the
word splitter read them as lowercase. That broke words in both directions:
- "msDž" (what ToPascalCase writes for "ms DŽ") had no boundary before the
digraph, so ToPascalCase was not idempotent ("MsDž" -> "Msdž") and
ToSnakeCase lost a word ("msdž" instead of "ms_dž"). (#156)
- "DžEMAL" had a camel hump after the digraph, so it split into "dž_emal",
"DŽ_EMAL" and "Dž Emal". (#106)
IsWordBoundary and EndsWordThatIsNotUppercase now count Lt as uppercase, so
one rule covers both directions. IsAllCaps also treats a titlecase digraph
followed directly by a capital as caps, so "DžEMAL" title-cases to "Džemal" the
same way "DŽEMAL" does. A lone "Dž" or "Džemal" is still not all caps.
Fixes #156
Fixes #106
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5pQJXg15qnY2s2Kwt
# Conflicts: # CaseConverter/CaseConverter.cs
|
matt-edmondson
added a commit
that referenced
this pull request
Nov 11, 2026
* Keep a titlecase digraph after an apostrophe in its word [patch] "a'Džemal" snaked to "a_džemal" while the two-letter spelling "a'Džemal" gives "adžemal". IsCapitalAfterApostropheInLowercaseContext tested char.IsUpper on the letter after the apostrophe, which is false for a titlecase digraph (category Lt), so the O'Neil rule never lowered it. SplitOnCaseChange then saw a lowercase-to-titlecase change and broke the word. The test now uses IsUpperOrTitlecase, as SplitOnCaseChange has since #158, so "a'Džemal" and "l'Ljubljana" give the same words as their two-letter spellings in every converter. Fixes #167 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2QxLJ6PwV5nQrv4Us * Move the apostrophe-suffix uppercase test into its own helper [patch] #169 widened the condition that uppercases a suffix onto the capital before an in-word apostrophe, which took ReplaceNonAlphaNumericWithSpace to a cognitive complexity of 17 (Sonar S3776, limit 15) and fails the quality gate. The condition now lives in IsSuffixUppercasedOntoCapital; behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2QxLJ6PwV5nQrv4Us --------- Co-authored-by: Claude <noreply@anthropic.com>
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 #156
Fixes #106
The triage on #156 asked for both to be fixed together, so a single rule for
TitlecaseLettercovers both directions.What was wrong
Dž,Lj,NjandDzare in category Lt, sochar.IsUpperreturnsfalsefor them and the word splitter treated them as lowercase."MsDž"ToPascalCase()MsdžMsDž(idempotent)"msDž"ToSnakeCase()msdžms_dž"LjubljanaLjubljana"ToPascalCase()Ljubljanaljubljana"DžEMAL"ToSnakeCase()/ToKebabCase()dž_emal/dž-emaldžemal"DžEMAL"ToMacroCase()DŽ_EMALDŽEMAL"DžEMAL"ToTitleCase()Dž EmalDžemalChange
IsUpperOrTitlecasehelper.IsWordBoundary(previousIsUpper/currentIsUpper) andEndsWordThatIsNotUppercaseuse it instead ofchar.IsUpper.IsAllCaps(public): a titlecase digraph followed directly by a capital no longer stops a string from being all caps. Without this,"DžEMAL"stayed asDžEMALunder title and Pascal case instead of becomingDžemalthe way"DŽEMAL"does. A loneDž,DžemalandADžare still not all caps. The XML doc states the new rule.Tests
AWordStartingWithATitlecaseDigraphShouldKeepItsBoundary: Pascal and camel case are idempotent for all four digraphs, and snake case agrees before and after.ACamelHumpAtATitlecaseDigraphShouldStartANewWord:"msDž".ToSnakeCase() == "ms_dž".ATitlecaseDigraphFollowedByCapitalsShouldStayInOneWord: the four rows from A titlecase digraph (Dž, Lj, Nj, Dz) followed by capitals is split off as its own word: "DžEMAL".ToSnakeCase() → "dž_emal", ToMacroCase() → "DŽ_EMAL" #106.IsAllCapsShouldCountATitlecaseDigraphBeforeACapitalAsCaps.With the source change reverted, 7 of these fail. With it, the full suite passes (221/221, net10.0).
Heads-up: the triage noted that open PRs #141, #143, #146, #147, #152, #153 and #155 also change the word-boundary code. This PR only changes three
char.IsUppercall sites and adds two helpers, so any conflict should be small.Generated by Claude Code