Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ICloneableX opened this issue Dec 21, 2024 · 0 comments

Comments

@ICloneableX
Copy link

ICloneableX commented Dec 21, 2024

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.

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

No branches or pull requests

1 participant