FROM : Aki Inoue
DATE : Tue Feb 12 21:01:21 2008
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_removed>)
>
> 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/<email_removed>
>
> This email sent to <email_removed>
DATE : Tue Feb 12 21:01:21 2008
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_removed>)
>
> 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/<email_removed>
>
> This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| James Hober | Feb 12, 20:58 | |
| Aki Inoue | Feb 12, 21:01 | |
| Sean McBride | Feb 12, 21:04 | |
| James Hober | Feb 12, 22:29 |






Cocoa mail archive

