• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSString ASCII filter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSString ASCII filter
      • From: "Sean McBride" <email@hidden>
    • Re: NSString ASCII filter
      • From: Aki Inoue <email@hidden>
  • Prev by Date: Re: Repetitive Appending of Strings
  • Next by Date: Re: NSString ASCII filter
  • Previous by thread: Re: Crash at THFSPlusStore::LessThan(HFSUniStr255 const&)
  • Next by thread: Re: NSString ASCII filter
  • Index(es):
    • Date
    • Thread