• 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
Re: NSString ASCII filter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSString ASCII filter (From: James Hober <email@hidden>)

  • Prev by Date: NSString ASCII filter
  • Next by Date: Re: NSString ASCII filter
  • Previous by thread: NSString ASCII filter
  • Next by thread: Re: NSString ASCII filter
  • Index(es):
    • Date
    • Thread