Frage

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?

War es hilfreich?

Lösung 2

I fix the issue with this method:

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

if you need you can replace more characters.

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top