-2

In Swift, how do I check if two Characters are the same ignoring case & diacritics?

1 Answer 1

0

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.