8

Suppose I have the String value with special accents :

éáüîāṁṇār̥

Is there a universal/dynamic way to convert/strip these types of characters down to a basic formatting like ?..

eauiamnar
Trip
  • 26,756
  • 46
  • 158
  • 277

1 Answers1

22

Use stringByFoldingWithOptions and pass .DiacriticInsensitiveSearch

let s = "éáüîāṁṇār̥"
let r = s.stringByFoldingWithOptions(.DiacriticInsensitiveSearch, locale: nil)
print(r) // prints eauiamnar
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
  • 1
    Another reference here.... http://stackoverflow.com/questions/29521951/how-to-remove-diacritics-from-a-string-in-swift – Pan Mluvčí Nov 22 '16 at 10:16