문제

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?

도움이 되었습니까?

해결책 2

I fix the issue with this method:

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

if you need you can replace more characters.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top