Skip to content

Humanize(), ApplyCase(), and Transform() all produce incorrect result when the input is in UPPERCASE #1557

@ICloneableX

Description

@ICloneableX

A similar issue has been raised before (in #1050) but was only fixed for one or two isolated cases. Several other cases are affected by this. Consider the following code:

var inputs = new[] { "WORD", "SPACE SEPARATOR", "HYPEN-SEPARATOR" };
foreach (string input in inputs)
{
    Console.WriteLine("Humanize>Title: ".PadRight(20) + input + " --> " + input.Humanize(LetterCasing.Title));
    Console.WriteLine("Humanize>Sentence: ".PadRight(20) + input + " --> " + input.Humanize(LetterCasing.Sentence));
    Console.WriteLine("ApplyCase>Title: ".PadRight(20) + input + " --> " + input.ApplyCase(LetterCasing.Title));
    Console.WriteLine("ApplyCase>Sentence: ".PadRight(20) + input + " --> " + input.Humanize(LetterCasing.Sentence));
    Console.WriteLine("Transform>Title: ".PadRight(20) + input + " --> " + input.Transform(To.TitleCase));
    Console.WriteLine("Transform>Sentence: ".PadRight(20) + input + " --> " + input.Transform(To.SentenceCase));
}

Output:

Humanize>Title:     WORD --> WORD ❌
Humanize>Sentence:  WORD --> WORD ❌
ApplyCase>Title:    WORD --> WORD ❌
ApplyCase>Sentence: WORD --> WORD ❌
Transform>Title:    WORD --> WORD ❌
Transform>Sentence: WORD --> WORD ❌
Humanize>Title:     SPACE SEPARATOR --> Space Separator ✔
Humanize>Sentence:  SPACE SEPARATOR --> Space separator ✔
ApplyCase>Title:    SPACE SEPARATOR --> SPACE SEPARATOR ❌
ApplyCase>Sentence: SPACE SEPARATOR --> Space separator ✔
Transform>Title:    SPACE SEPARATOR --> SPACE SEPARATOR ❌
Transform>Sentence: SPACE SEPARATOR --> SPACE SEPARATOR ❌
Humanize>Title:     HYPEN-SEPARATOR --> HYPEN SEPARATOR ❌
Humanize>Sentence:  HYPEN-SEPARATOR --> HYPEN SEPARATOR ❌
ApplyCase>Title:    HYPEN-SEPARATOR --> HYPEN-SEPARATOR ❌
ApplyCase>Sentence: HYPEN-SEPARATOR --> HYPEN SEPARATOR ❌
Transform>Title:    HYPEN-SEPARATOR --> HYPEN-SEPARATOR ❌
Transform>Sentence: HYPEN-SEPARATOR --> HYPEN-SEPARATOR ❌

Tested on Humanizer.Core 2.14.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions