Re: characterAtIndex: method and composite characters (SOLVED)
Re: characterAtIndex: method and composite characters (SOLVED)
- Subject: Re: characterAtIndex: method and composite characters (SOLVED)
- From: Douglas Davidson <email@hidden>
- Date: Wed, 4 Apr 2007 12:04:00 -0700
On Apr 4, 2007, at 11:55 AM, Ewan Delanoy wrote:
Thanks Douglas for your post ; it completes Greg's one well.
The additional information you provide will certainly be useful
for me, although not this time : the particular case I was
dealing with here was a line-sorter (to sort an index) based on
an unusual character ordering (some items in the index
start with accentuated characters), which is exactly the kind
of "special circumstances" you mention.
For sorting I would generally recommend one of the NSString methods
with "compare" in their names; they will properly handle Unicode-
conformant comparison. If you are sorting user-visible strings, it's
usually best to use the user's preferred sort ordering, which the
locale-sensitive compare methods will do. Sort ordering generally
can be quite complicated--for example, some locales treat certain
pairs of ordinary characters as one for the purposes of sorting--so
it's best to let NSString do the work. I wouldn't call the presence
of accented characters an unusual circumstance; in most European
languages, accented characters are quite common, and may themselves
have special sorting rules.
Douglas Davidson
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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