Skip to content

Lowercase a word-final capital sigma to final sigma [patch] - #130

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/127-final-sigma
Oct 18, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/127-final-sigma

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #127

Before: every lowercasing path used the invariant (simple) mapping, so a capital Σ always came out as the medial σ, even at the end of a word. "ΛΟΓΟΣ".ToSnakeCase() gave λογοσ, and "λόγος".ToMacroCase().ToSnakeCase() gave λόγοσ even though "λόγος".ToSnakeCase() is λόγος.

After: a word-final Σ lowercases to ς in snake, kebab, Pascal, camel and Title Case. A lone Σ and a word-initial Σ still give σ ("ΣΑΣ" → σας).

How: a new ToLowerInvariantWithFinalSigma applies Unicode's Final_Sigma condition: a cased letter comes before the Σ and none comes after it, skipping case-ignorable characters such as combining marks and apostrophes. ToLowerInvariantFull now builds on it, and LowercaseAllCapsWords uses it in place of plain ToLowerInvariant(). That keeps the existing rule that İ is left for title-casing there. The invariant mapping maps one char to one char, so indexes in the input and output line up.

Tests: I added AWordFinalCapitalSigmaShouldLowercaseToFinalSigma, which covers every example from the issue in five formats, and GreekWithFinalSigmaShouldConvertTheSameFromItsMacroCaseSpelling. With the library change reverted, 6 of them fail. With it, all 174 tests pass. The library builds cleanly for net10.0, net9.0, net8.0, netstandard2.0 and netstandard2.1.


Generated by Claude Code

Every lowercasing path used the invariant (simple) mapping, which turns
"Σ" into the medial "σ" even at the end of a word. Apply Unicode's
Final_Sigma condition in ToLowerInvariantFull and in LowercaseAllCapsWords,
so "ΛΟΓΟΣ" converts to "λογος" in every format and Greek converts the same
from its MACRO_CASE spelling as from its lowercase one.

Fixes #127

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

All-caps Greek words lose their final sigma: "ΛΟΓΟΣ".ToSnakeCase() gives "λογοσ" instead of "λογος"

2 participants