On 11.08.2008, at 15:29, Ron Fleckner wrote:
NSString *str = @"Aa";
char first = [str characterAtIndex:0];
char second = [str characterAtIndex:1];
NSLog(@"%c is [EMAIL PROTECTED]", first, isupper(first) ? @"uppercase" :
@"lowercase");
NSLog(@"%c is [EMAIL PROTECTED]", second, isupper(second) ? @"uppercase" :
@"lowercase");
Result:
A is uppercase.
a is lowercase.
Bad Idea (tm):
You're discarding the high byte of the unichar that characterAtIndex:
returns by casting it to a regular char, so isupper() might get to see
a completely different character than the user sees.
Second, Unicode can have decomposed character sequences, so the glyph
at that particular index may actually be several characters long, and
you're only analyzing the first one.
NSCharacterSet is probably your best bet. You could check whether
whatever character you're looking at is a member of the
uppercaseLetterCharacterSet.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]