12 years ago.

"ctype.h" is not part of mbed's C library?

Hello, I am trying to use int isascii (int c) to check if some of the characters arriving from a serial device are garbage chars to be ignored or ascii to be processed, however it seems that the ctype.h include doesn't work. Does anyone have any insights? Regards, Evgheni C

1 Answer

12 years ago.

Including ctype.h works fine for me. No specific knowledge of those functions, but according to the C++ reference (http://www.cplusplus.com/reference/cctype/) isascii is not a function there. Granted a google shows it is used often, but I dont know if it is part of the official standard.

That said, why do you need the function? Checking if something is an ascii char is straightforward: just check if it is smaller than 128. If you put it in a signed variable also check if it is larger than zero, but if it is just in a normal char that wont be needed.

Accepted Answer

Thank you Eric, in the end I did end up writing the check as a macro, I was just surprised that ascii() wasn't working, should have checked other functions in ctype.h before ringing the alarm...

posted by Evgheni Cr 25 Dec 2012