Re: case-insensitive but case-ordered sort
Re: case-insensitive but case-ordered sort
- Subject: Re: case-insensitive but case-ordered sort
- From: Kyle Sluder <email@hidden>
- Date: Tue, 20 Jul 2010 12:46:18 -0700
On Tue, Jul 20, 2010 at 11:04 AM, Charlie Dickman <email@hidden> wrote:
> You should be able to accomplish what you want using NSPredicate.
NSPredicate will just wind up falling through to the same sorting
methods Roland can call directly.
> You can also use the C functions topper and tolower to detect and distinguish case differences.
Don't do this.
1. These functions are ASCII only. (Although the man page mentions
they extend the standard and support multibyte characters, but that
support could go away.)
2. C wide-character support is not as correct as CFString's. Since you
already have an NSString, it's trivial to use the
CFStringUppercase/CFStringLowercase/CFStringCapitalize API to
correctly change case depending on language:
http://lists.apple.com/archives/cocoa-dev/2009/May/msg00234.html
3. Why convert case when you can compare case- (and
diacritic-)insensitive directly using the CFStringCompareWithOptions
API?
In short, Core Foundation is more correct than your code, unless you
are or plan on hiring a linguistic scholar.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden