Re: Localized string compare borked?
Re: Localized string compare borked?
- Subject: Re: Localized string compare borked?
- From: David Remahl <email@hidden>
- Date: Mon, 19 May 2003 23:52:43 +0200
Joar,
I don't spot any errors in your code...I assume the user has the
International preference pane to have the Swedish set of behaviours at
the top of the list?
I would try the following as an alternative:
- (NSComparisonResult)localizedCaseInsensitiveCompare:(id)obj
{
NSComparisonResult result = NSOrderedSame;
if( [obj isKindOfClass:[self class]] )
{
result = (NSComparisonResult)CFStringCompare( (CFStringRef)[self
stripDisplayName], (CFStringRef)[obj stripDisplayName],
kCFCompareNumerically | kCFCompareLocalized |
kCFCompareCaseInsensitive );
}
return result;
}
and see if that brings you any closer to the result you require.
/ Rgds, David
On Monday, May 19, 2003, at 11:26 PM, j o a r wrote:
Hej,
My user want to see their lists sorted in accordance with their
Swedish locale. We have extra characters at the end of our alphabet
(after Z, wohoo!), but they get sorted among their ASCII siblings A
and O no matter what I try.
Included is a shot at a comparison method that I've implemented in one
of my objects in futile attempts to get it sorted properly:
- (NSComparisonResult) localizedCaseInsensitiveCompare:(id) obj
{
NSComparisonResult result = NSOrderedSame;
if ([obj isKindOfClass: [self class]])
{
result = [[self stripDisplayName] localizedCaseInsensitiveCompare:
[obj stripDisplayName]];
/*
result = [[self stripDisplayName] compare: [obj stripDisplayName]
options: NSCaseInsensitiveSearch
range: NSMakeRange(0, [[self stripDisplayName] length])
locale: [[NSUserDefaults standardUserDefaults]
dictionaryRepresentation]];
*/
}
return result;
}
Can you spot the bug, or do you have some other helpful suggestions?
I looked for answers in the docs, at ADC and Mamasam but found very
little on the topic. Something missing in Mac OS X 10.2?
Anyone else noted that the Cocoa reference docs seems to be missing
from developer.apple.com - an update in the works, or more things
borked?
j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.