In Swift, how do I check if two Character
s are the same ignoring case & diacritics?
1 Answer
I am not really sure what you mean by "are the same"
But you can do this to check if they are diacritics:
import Foundation
let letters = CharacterSet.decomposables
let phrase = "AaBbÖöÈè8I"
for uni in phrase.unicodeScalars {
if letters.contains(uni) {
print(uni)
}
}
//Prints: ÖöÈè
I presume that there also is a set of ignoring case characters that you could compare your string to.