Another pitfall. Signed chars and ctype.h.

John Woods john at frog.UUCP
Fri Feb 9 16:59:00 AEST 1990


In article <Chsv$q2 at cs.psu.edu>, flee at shire.cs.psu.edu (Felix Lee) writes:
> If you have "char * s;" you cannot say something like "isdigit(*s)" if
> you want to be 8-bit clean.  "isdigit" etc. take an (int) in the range
> [-1, UCHAR_MAX].
> You have to say "isdigit((unsigned char) *s)".

You have ahold of the wrong end of the stick.

You have to say

	isascii(*s) && isdigit(*s)

isdigit() and friends are all only defined on those values for which
isascii() is true.  If your vendor declares that isascii((char)0x85) is
true, then isdigit((char)0x85) better be made to work, one way or another.
-- 
John Woods, Charles River Data Systems, Framingham MA, (508) 626-1101
...!decvax!frog!john, john at frog.UUCP, ...!mit-eddie!jfw, jfw at eddie.mit.edu



More information about the Comp.lang.c mailing list