Skip to content

Pascal/Camel/Snake/Kebab/Macro delete Unicode letter-number characters: "chapter Ⅻ".ToPascalCase() → "Chapter", "Ⅻ".ToSnakeCase() → "" #105

Description

@matt-edmondson

What's wrong

ReplaceNonAlphaNumericWithSpace keeps a code point only if char.IsLetter is true or it is '0'..'9'. Characters in category LetterNumber (Nl) fail both tests, so they are replaced with a space and dropped. Nl covers the Roman numeral characters Ⅰ–ↈ and ⅰ–ⅿ (U+2160–U+2188), Gothic and Old Persian number letters, and similar characters. These characters are cased (Ⅻ ↔ ⅻ), and ToLowercaseFirstChar already maps between the two forms. ToTitleCase does not go through this path and keeps them, so the converters disagree on the same input.

Repro (main @ 4a74d14)

Input Call Actual Expected
"chapter Ⅻ" ToTitleCase() Chapter Ⅻ (correct)
"chapter Ⅻ" ToPascalCase() Chapter ChapterⅫ
"chapter Ⅻ" ToSnakeCase() / ToMacroCase() chapter / CHAPTER chapter_ⅻ / CHAPTER_Ⅻ
"Ⅻ" ToPascalCase() / ToSnakeCase() "" Ⅻ / ⅻ

Why it matters

Text is deleted with no error, and an input made only of these characters becomes the empty string. This is the same class of bug as #70 (astral letters deleted) and #80 (combining marks and non-ASCII digits deleted). #80 covers marks and char.IsDigit but not LetterNumber, so its fix would not cover this case.

Suggested fix

In ReplaceNonAlphaNumericWithSpace, also keep code points whose CharUnicodeInfo.GetUnicodeCategory is LetterNumber. Decide whether IsWordBoundary treats them as letters (no break in "chapterⅫ") or as digits (a break), and apply the choice the same way in every converter. Add rows for "chapter Ⅻ" and "Ⅻ" across every converter.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions