Why we should use uppercaseStringWithLocale of NSString to get correct uppercase string?

ios, macos, objective-c, unicode

Solution

The docs say:

The following methods perform localized case mappings based on the locale specified. Passing nil indicates the canonical mapping. For the user preference locale setting, specify +[NSLocale currentLocale].

Assumedly in some locales the mapping from lowercase to uppercase changes even within a character set. I'm not an expert in every language around the globe, but the people who wrote these methods are, so I use 'em.

Problem

I have a very simple task: from server I get `UTF-8` string as byte array and I need to show all symbols from this string in upper case. From this string you can get really any symbol of unicode table. I know how to do it in a line of code: ``` NSString* upperStr = [[NSString stringWithCString:utf8str encoding:NSUTF8StringEncoding] uppercaseString]; ``` And seems to me it works with all symbols which I have checked. But I don't understand: why we need method uppercaseStringWithLocale? When we work with unicode each symbol has unique place in unicode table and we can easily find does it have upper/lower case representation. What trouble I might have if I use `uppercaseString` instead `uppercaseStringWithLocale`?

Original source