What's wrong
Elsewhere the library treats U+2019 (the typographic apostrophe) the same as ASCII ' (see IsApostropheWithinWord and IsWordCharacter). ToTitleCase (CaseConverter/CaseConverter.cs, ~line 322) passes the text to CultureInfo.InvariantCulture.TextInfo.ToTitleCase, and that method only special-cases ASCII '. It treats U+2019 as a word separator and capitalizes the letter after it. The #75 fix therefore covers only the ASCII form.
Observed on main (1c1c555):
"don’t stop".ToTitleCase() gives Don’T Stop; expected Don’t Stop
"it’s fine" gives It’S Fine
"API’s" gives API’S
- ASCII
"don't stop" gives Don't Stop (correct)
Text pasted from word processors, macOS and web pages uses smart quotes by default, so this is easy to hit. Confirmed with a temporary MSTest.
Suggested fix
In ToTitleCase, replace each in-word U+2019 (IsApostropheWithinWord) with ASCII ' before calling TextInfo.ToTitleCase, and put the U+2019 back at the same indices afterwards. ToTitleCase does not change the string's length, so restoring by index is safe.
Acceptance: add "don’t stop" and "it’s fine" rows to the ToTitleCase tests.
What's wrong
Elsewhere the library treats U+2019 (the typographic apostrophe) the same as ASCII
'(seeIsApostropheWithinWordandIsWordCharacter).ToTitleCase(CaseConverter/CaseConverter.cs, ~line 322) passes the text toCultureInfo.InvariantCulture.TextInfo.ToTitleCase, and that method only special-cases ASCII'. It treats U+2019 as a word separator and capitalizes the letter after it. The #75 fix therefore covers only the ASCII form.Observed on
main(1c1c555):"don’t stop".ToTitleCase()givesDon’T Stop; expectedDon’t Stop"it’s fine"givesIt’S Fine"API’s"givesAPI’S"don't stop"givesDon't Stop(correct)Text pasted from word processors, macOS and web pages uses smart quotes by default, so this is easy to hit. Confirmed with a temporary MSTest.
Suggested fix
In
ToTitleCase, replace each in-word U+2019 (IsApostropheWithinWord) with ASCII'before callingTextInfo.ToTitleCase, and put the U+2019 back at the same indices afterwards.ToTitleCasedoes not change the string's length, so restoring by index is safe.Acceptance: add
"don’t stop"and"it’s fine"rows to the ToTitleCase tests.