Hashem Aboonajmi
Hashem Aboonajmi

Reputation: 13890

can't search in farsi text with arabic keyboard on iphone

I have recently developed a book for iphone and implemented search function in this app. but after testing the app on a real iphone I wondered it cant find all of the search Terms. (using farsi keyboard on my mac)

for example it cant find words containing "ی" character because the search terms contains "ي" character which is inserted from iphone arabic keyboard!!

my texts are a lot and I cant find all of theses similar characters!!

Is there any way to convert my farsi text to arabic text?

Upvotes: 2

Views: 909

Answers (2)

Hashem Aboonajmi
Hashem Aboonajmi

Reputation: 13890

I fix the issue with this method:

- (NSString *)correctSearchTermCharcters:(NSString *)searchTerm
{
    return [searchTerm stringByReplacingOccurrencesOfString:@"ي" withString:@"ی"];
}

if you need you can replace more characters.

Upvotes: 0

bames53
bames53

Reputation: 88215

You probably need to normalize the text or use a search routine that is insensitive to the various Arabic letter forms (initial, medial, final, isolated), or insensitive to diacritics.

In particular 'ي' is U+064A 'ARABIC LETTER YEH' while 'ی' is U+FBFC 'ARABIC LETTER FARSI YEH ISOLATED FORM'.

You might look at the method localizedCaseInsensitiveCompare: or the various search options such as to NSDiacriticInsensitiveSearch.

Here's a blog post discussing the issue, though it doesn't actually say how to solve the problem: http://www.siao2.com/2006/02/14/531572.aspx

Upvotes: 1

Related Questions