Is this method for capitalizing a string safe with Unicode?

Viewed 90

Make first letter of a string upper case (with maximum performance) suggests various methods for making only the first character of a string uppercase.

All of them though are essentially the equivalent of this:

char.ToUpperInvariant(st[0]) + str.Substring(1)

I don't know enough about the unicode spec to know if this is actually safe. Could you ever have a code point which is more than 1 char wide which could be capitalized?

Note that chars in C# are UTF16, and that ToUpperInvariant ultimately calls the operating system APIs to uppercase the char

0 Answers
Related