Re: NSString: localizedCaseInsensitiveCompare + NSNumericSearch?
Re: NSString: localizedCaseInsensitiveCompare + NSNumericSearch?
- Subject: Re: NSString: localizedCaseInsensitiveCompare + NSNumericSearch?
- From: Aki Inoue <email@hidden>
- Date: Tue, 21 Mar 2006 22:36:38 -0800
Jim,
return [string1 compare: string2 options: (NSCaseInsensitiveSearch
| NSNumericSearch) range: NSMakeRange(0, [string1 length]) locale:
locale];
That's the correct expression.
We have a plan to introduce a set of new APIs in CFString/NSString
that take CFLocale/NSLocale instead of the current
kCFCompareLocalized/NSDictionary-based locale approaches in a future
release.
Aki
I have two strings that I'd like to do a localized, case
insensitive compare where digits are compared numerically.
There doesn't appear to be a Foundation equivalent of
kCFCompareLocalized.
What is the correct way to express this in Foundation?
static int sort_func(id string1, id string2, void * context)
{
NSDictionary *locale = [[NSUserDefaults standardUserDefaults]
dictionaryRepresentation];
return [string1 compare: string2 options: (NSCaseInsensitiveSearch
| NSNumericSearch) range: NSMakeRange(0, [string1 length]) locale:
locale];
}
(I know with toll free bridging that I can use CF, but I want to
know what the objective C syntax is so I can add an appropriate
category to NSString.)
This appears to give me the same result collation order as the
Finder (using Deborah Goldsmith's advice of checking against
Hawaiian.)
Thanks,
Jim
_______________________________________________
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
_______________________________________________
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