Uppercase All String According to Locale - Swift
NSLocale.currentLocale()
is the locale which was selected in the
Settings of the device. If that is "en_US" then
text.uppercaseStringWithLocale(NSLocale.currentLocale())
will use the english language rules and the result is "ISTANBUL, IZMIR".
You can either select the turkish language in the device settings, or specify the turkish locale explicitly:
let text = "istanbul, izmir"
text.uppercaseStringWithLocale(NSLocale(localeIdentifier: "tr"))
// İSTANBUL, İZMİR
Swift 3:
text.uppercased(with: Locale(identifier: "tr"))
If you want to use the current locale, you can use:
text.localizedUppercaseString