Skip to content

Split an acronym from a following decomposed accented word [patch] - #121

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/113-nfd-acronym-tail
Oct 14, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/113-nfd-acronym-tail

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

The acronym-tail rule ("XMLDoc" breaks before the D) checked the code point straight after a capital to see whether a lowercase letter followed. In NFD an accented capital is E + U+0301, so that code point is the combining mark. No break was inserted and the acronym merged into the next word:

Input (NFD) Method Before After (same as NFC)
getIDÉtat ToSnakeCase() get_idétat get_id_état
XMLÉtude ToSnakeCase() xmlétude xml_étude
XMLÉtude ToPascalCase() Xmlétude XmlÉtude

Changes

  • New SkipOverCombiningMarks helper, the forward counterpart to SkipBackOverCombiningMarks. IsWordBoundary uses it before SkipLowercaseWithNoUppercase so that casedNextStart lands on the next base letter.
  • IsPluralSuffix no longer counts an s followed by a combining mark as a plural s. The composed ś isn't one either, so NFD IDś now converts the same as NFC. The issue suggested skipping the mark here as well, but skipping would have kept NFD IDś whole while NFC IDś splits, so this matches NFC instead.

Tests

  • AnAccentedCapitalAfterAnAcronymShouldConvertLikeItsComposedSpelling checks getIDÉtat, XMLÉtude and IDś in NFD against their NFC spellings in every case style.
  • AnAcronymBeforeADecomposedAccentedWordShouldSplitFromIt pins the exact snake_case and PascalCase output.
  • The test host runs with invariant globalization, where string.Normalize does nothing, so each test writes out the composed spelling instead of normalizing.
  • With only the source change reverted, all 5 new cases fail. With it, all 160 tests pass, and dotnet build CaseConverter.sln finishes with 0 warnings and 0 errors.

#112, the apostrophe half of the same NFD problem, is in its own PR (#120). The two branches don't touch the same lines.

Fixes #113

🤖 Generated with Claude Code

https://claude.ai/code/session_01Te9V62v8CvS3Mj4gFs7ty3


Generated by Claude Code

The acronym-tail rule ("XMLDoc" breaks before the "D") checked the code
point straight after a capital for a lowercase letter. In NFD an accented
capital is "E" + U+0301, so that code point was the combining mark, no
break was inserted, and the acronym merged into the next word: NFD
"getIDÉtat" gave "get_idétat" and "XMLÉtude" gave "Xmlétude", where the
NFC spellings gave "get_id_état" and "XmlÉtude".

IsWordBoundary now skips forward over combining marks before looking for
that lowercase letter. IsPluralSuffix no longer takes an "s" carrying a
combining mark for a plural "s", matching the composed "ś", so NFD "IDś"
converts the same as NFC.

Fixes #113

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Te9V62v8CvS3Mj4gFs7ty3
@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

Development

Successfully merging this pull request may close these issues.

Acronym followed by a decomposed (NFD) accented word doesn't split: "getIDÉtat" → "get_idétat"

2 participants