Osama Khan Osama Khan - 1 year ago 50
iOS Question

Search arabic text while ignoring diacritics or accents

Search feature works fine when I use the Arabic with the vowels (fatha, kasra, etc.). How can I search the Arabic text while being vowels/accents insensitive?

For example, if I search for واليوم it should display all results like وَالْيَوْمِ

This is the code I use with vowels (diacritics).

let arabicMatch = Dua.arabic.rangeOfString(searchText, options: NSStringCompareOptions.CaseInsensitiveSearch)

For swift and iOS 9.

Answer Source

NSStringCompareOptions also has a DiacriticInsensitiveSearch you can use (in the same way as the case insensitive).