Reputation: 57
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.
Upvotes: 2
Views: 978
Reputation: 855
or you can make normalize string
extension String {
func normalizeArabic() -> String {
let newString = NSMutableString(string: self) as CFMutableString
CFStringTransform(newString, nil, kCFStringTransformLatinArabic, Bool(truncating: 0))
CFStringTransform(newString, nil, kCFStringTransformStripCombiningMarks, Bool(truncating: 0))
return newString as String
}}
Upvotes: 0
Reputation: 119031
NSStringCompareOptions
also has a DiacriticInsensitiveSearch
you can use (in the same way as the case insensitive).
Upvotes: 5