Ignore accents when comparing strings
Ignore accents when comparing strings
- Subject: Ignore accents when comparing strings
- From: "Simon alias Trax" <email@hidden>
- Date: Wed, 05 Jan 2005 06:52:45 +0000
When I compare two NSStrings, I want the accented characters be treated as
regular characters. For example, if "é" is found in a string, it will act
like "e" and "ê" and so on. Another example : "parle" and "parlé" will be
considered the same when compared.
I'm doing this, through the method sortUsingSelector:@selector(compare:) (I
can't use anything else since I don't know how to pass parameters within
this method.
Here's a real-life example :
NSString *mot1 = @"arc";
NSString *mot2 = @"a";
NSString *mot3 = @"à";
NSMutableArray *sim = [NSMutableArray arrayWithObjects:mot1,mot2,mot3,nil];
NSLog(@"%@",sim);
NSLog(@"---");
[sim sortUsingSelector:@selector(compare:)];
NSLog(@"%@",sim);
The logs show me what happened. "à" is supposed to be equivalent to "a", not
after, not before.
So the correct sorting should be, in ascending order : "a","à","arc". But
the computer sort of thinks "à" as the second letter of the alphabet. So I
get the wrong result : "a","arc","à".
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden