I was trying to use TextInfo.ToTitleCase
to convert some names to proper case. it works fine for strings in lowercase and mixed case but for strings with all characters in upper case, it returns the input string as is.
Nothing about this behavior is mentioned in MSDN documentation, any insights?
From MSDN docs:
Remarks Generally, title casing converts the first character of a word to uppercase and the rest of the characters to lowercase. However, this method does not currently provide proper casing to convert a word that is entirely uppercase, such as an acronym. The following table shows the way the method renders several strings.
so it's expected behaviour. You could lowercase your string first if it's all uppercase, then run ToTitleCase on it.
I suspect it's because words in all capitals are expected to be abbreviations such as USA.
For example, you wouldn't expect "Earthquake hits USA" to be changed to "Earthquake Hits Usa" would you?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With