Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone: NSComparisonResult and NSDiacriticInsensitiveSearch issue Scandinavian alphabets
    primarykey
    data
    text
    <p>I use NSComparisonResult for searching through my array, but when I use NSDiacriticInsensitiveSearch, it cant find immediately Scandinavian alphabets like å æ ø, but it can find such alphabets as á etc. When I remove NSDiacriticInsensitiveSearch in options: , then my search bar can find å æ ø immediately, but ignore à and such. </p> <p>Is there any solution to this?</p> <p>EDIT 15 august: I believe using NSScanner (though I have no experience with this) in if logic for detecting å æ ø in searchstring, if they exist, then no nsdiactricinsensitivesearch. If no å æ ø in searchstring, then include nsdiactricinsensitivesearch in nscomparisonresult. I will try to implement this soon and give feedback if this works or not. </p> <hr> <p>My codes:</p> <pre><code>NSComparisonResult result; NSString *setext = searchText; NSScanner *scanner = [NSScanner scannerWithString:setext]; NSString *a = @"å"; while ([scanner isAtEnd] == NO) { if ( [scanner scanString:a intoString:NULL]) { [scanner scanUpToString:a intoString: NULL]; result = [mystr compare:searchText options:(NSCaseInsensitiveSearch) range:NSMakeRange(0, [searchText length])]; } else { result = [mystr compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])]; } } </code></pre> <p>But it is a bit slower than my modification of JohnBrighton´s solution:</p> <pre><code> NSComparisonResult result; NSString *string = searchText; NSRange range = [string rangeOfString:@"æ"]; NSRange range2 = [string rangeOfString:@"ø"]; NSRange range3 = [string rangeOfString:@"å"]; if (range.location != NSNotFound || range2.location != NSNotFound || range3.location != NSNotFound ) //if ((range.location != NSNotFound) | (range2.location != NSNotFound ) | (range3.location != NSNotFound ) ) { { result = [mystr compare:searchText options:(NSCaseInsensitiveSearch) range:NSMakeRange(0, [searchText length])]; } else { result = [mystr compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])]; } </code></pre> <hr> <p>Does anyone know whats the difference between || and | in if logic?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload