Re: -[NSString localizedCompare:] - example of semantic difference with compare?
Re: -[NSString localizedCompare:] - example of semantic difference with compare?
- Subject: Re: -[NSString localizedCompare:] - example of semantic difference with compare?
- From: Ricky Sharp <email@hidden>
- Date: Mon, 27 Mar 2006 16:22:12 -0600
On Mar 27, 2006, at 4:09 PM, Aki Inoue wrote:
Ricky,
CFComparisonResult theCFResult =
CFStringCompareWithOptions ((CFStringRef) self,
(CFStringRef) anItemName, CFRangeMake (0,
CFStringGetLength ((CFStringRef) self)),
kCFCompareCaseInsensitive | kCFCompareLocalized |
kCFCompareNumerically);
I recommend also using kCFCompareNonliteral here. Without it,
CFString doesn't compare attached and detached accents equally
which is essential to most localized sorting.
Thanks for pointing that out. After reading up on that constant, I
see why it's important.
You might want to file a bug against NSString to add either
localizedCompare:withOptions:, or to add a NSLocalizedSearch option.
Will definitely do this tonight; I'll actually request both
options just for completeness sake.
The API actually exists.
Refer to -[NSString compare:options:range:locale:].
I missed that one somehow! Now then, it says that the only options
you can use are
NSCaseInsensitiveSearch
NSLiteralSearch
NSNumericSearch
I'm thus going to assume the following combination of options passed
to compare:options:range:locale:
NSCaseInsensitiveSearch | NSNumericSearch
is functionally equivalent to these options passed to
CFStringCompareWithOptions:
kCFCompareInsensitive | kCFCompareLocalized |
kCFCompareNumerically | kCFCompareNonliteral
i.e. by not specifying NSLiteralSearch, it will attempt to compare
the attached and detached combining marks correctly.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
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