Given a null-terminated char array what is the most efficient method to validate that each byte contains a valid ASCII character (i.e. A-Z, 0-9, CR, LF, ..).
Actually that sounds great. I hadn't heard of __isascii before and will try it out. Seems like that will require less lines of code than what I was thinking of....thanks for the time./j
isascii() returns true for all characters between 0x00 & 0x7F (which includes a lot of non-printable characters).
You might be better off using isprint() which only returns true for chars 0x20 to 0x7E.
Oops, missed that part. But it still depends on what kind of data he's trying to validate. If it's text data, then isascii() will let a lot of junk through. In that case you'd need to use both isprint() and isspace().
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.