Re: NSString comparison with locale single character error
Re: NSString comparison with locale single character error
- Subject: Re: NSString comparison with locale single character error
- From: Deborah Goldsmith <email@hidden>
- Date: Wed, 15 Nov 2006 18:43:48 -0800
If you want the first character, you have to use:
[sortString substringWithRange:[sortString
rangeOfComposedCharacterSequenceAtIndex:0]]
to handle characters that contain more than one code point. Try
fixing that first.
If it still doesn't work, please write a bug.
Deborah Goldsmith
Internationalization, Unicode Liaison
Apple Computer, Inc.
email@hidden
On Nov 15, 2006, at 1:12 PM, Conor Dearden wrote:
Hi David,
I have tried all of the following three ways with the same results:
NSComparisonResult localizedCompare = [previousLetter
compare:thisLetter
options:nil range:NSMakeRange(0,[previousLetter length])
locale:[[NSUserDefaults standardUserDefaults]
dictionaryRepresentation]];
localizedCompare = [previousLetter localizedCompare:thisLetter];
localizedCompare = CFStringCompareWithOptions((CFStringRef)
previousLetter, (CFStringRef)thisLetter, CFRangeMake (0,
CFStringGetLength
((CFStringRef) previousLetter)), kCFCompareNonliteral |
kCFCompareCaseInsensitive | kCFCompareLocalized );
The letter comes from the longer word by using the methods:
NSString *thisLetter = [[sortString substringToIndex:1]
uppercaseString];
Conor Dearden
http://www.bruji.com/
David Duncan wrote:
I have a problem I can't seem to get around. The letter A and Ä in
German
are sorted equally as part of A. "Ärzte" belongs between "Arsene"
and "
Astronaut". When using localizedCompare: or
compare:options:range:locale: I
get the correct results when sorting the words, meaning that A and
Ä are
NSOrderedSame and the results are based on the second or third
letters in
the word. My problem is when comparing the single letters "A" and "
Ä" I get
that A belongs before Ä and do not get NSOrderedSame.
How are you doing the single letter comparison?
_______________________________________________
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