Re: Ignore accents when comparing strings
Re: Ignore accents when comparing strings
- Subject: Re: Ignore accents when comparing strings
- From: j o a r <email@hidden>
- Date: Wed, 5 Jan 2005 09:13:40 +0100
On 2005-01-05, at 07.52, Simon alias Trax wrote:
NSString *mot3 = @"à";
Have you read the definition of the ObjC static string?
<http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/
LanguageSummary/chapter_5_section_5.html#//apple_ref/doc/uid/20001428-
DontLinkElementID_834204>
There are no accented characters in the 7-bit ASCII character set,
right? Search the list archives for more info on that topic.
The logs show me what happened. "à" is supposed to be equivalent to
"a", not after, not before.
Why should these two strings be equivalent? They're not (at least not
in my opinion)!
Anyhow. For an example of things to consider, check the list archives
and a message from Ali Ozer in the thread "Sorting unicode strings".
Consider creating a category on NSString that compares the way you want
to:
@interface NSString (MySearchAdditions)
- (NSComparisonResult)literalCompare:(NSString *)string;
@end
@implementation NSString (MySearchAdditions)
- (NSComparisonResult)literalCompare:(NSString *)string
{
return [self compare: string options: NSLiteralSearch]; // Or using
any other search options you like
}
@end
Now you can compare using your comparison method:
[sim sortUsingSelector: @selector(literalCompare:)];
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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