Re: NSString ASCII filter
Re: NSString ASCII filter
- Subject: Re: NSString ASCII filter
- From: Aki Inoue <email@hidden>
- Date: Tue, 12 Feb 2008 12:01:21 -0800
This should be reasonably efficient.
Aki
On 2008/02/12, at 11:58, James Hober wrote:
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
_______________________________________________
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