NSString ASCII filter
NSString ASCII filter
- Subject: NSString ASCII filter
- From: James Hober <email@hidden>
- Date: Tue, 12 Feb 2008 11:58:13 -0800
What is the simplest, reasonably efficient way to determine if an
NSString contains a non-ASCII character?
What I came up with was:
NSCharacterSet *nonASCII = [[NSCharacterSet
characterSetWithRange:NSMakeRange(0, 128)] invertedSet];
NSRange nonASCIIRange = [testString
rangeOfCharacterFromSet:nonASCII];
if (nonASCIIRange.location != NSNotFound)
{
NSLog(@"got a non-ASCII character");
}
Thanks,
James
_______________________________________________
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