String Transform¶
Antigo CFStringTransform
@available(iOS 9.0, *)
let text = "🍕".stringByApplyingTransform(NSStringTransformToUnicodeName, reverse: false)
print(text)
// {SLICE OF PIZZA}
let text = "Luna".stringByApplyingTransform(NSStringTransformLatinToCyrillic, reverse: false)
print(text)
// Луна
let text = "您好".stringByApplyingTransform(NSStringTransformMandarinToLatin, reverse: false)
print(text)
// nín hǎo
let text =
"您好"
.stringByApplyingTransform(NSStringTransformMandarinToLatin, reverse: false)
.stringByApplyingTransform(NSStringTransformStripDiacritics, reverse: false)
print(text)
// nin hao
let text = "Αθήνα".stringByApplyingTransform("Any-Latin; Latin-ASCII; Lower", reverse: false)
print(text)
// athena
Last update: July 17, 2020