FROM : James Hober
DATE : Tue Feb 12 20:58:13 2008
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
DATE : Tue Feb 12 20:58:13 2008
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
| 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

