[comp.lang.c] Re^2: Another pitfall. Signed chars and ctype.h.

web@kivax.UUCP (Heinz Weber) (02/13/90)

john@frog.UUCP (John Woods) writes:

>In article <Chsv$q2@cs.psu.edu>, flee@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.  

You are right, this is what's defined in the X/OPEN Portability Guide.
But you don't meet the problem. I want German Umlauts to be no space
char's and printable an so on, e.g. the german "oe", that is 0xf6 in
the international char set. I'm not interested in isascii(0xf6) = not true!
So, the only chance you have is to take unsigned char to get the right
index into the ctype-vector.

Heinz

------------------------------------------------------------------------
Heinz Weber              voice:  +49 7721 867034          * In all probability
Mannesmann Kienzle GmbH                                   * this is once again
Abt. 013.21              e-mail: web@kivax.UUCP           * only my opinion !
Postfach 1640                    ..!mcsun!unido!kivax!web
D-7730 VS-Villingen              ..!uunet!unido!kivax!web
West Germany