Path: utzoo!utgpu!attcan!uunet!lll-winken!arisia!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Programming and international chara Message-ID: <644@quintus.UUCP> Date: 8 Nov 88 02:30:45 GMT References: <532@krafla.rhi.hi.is> <44200016@uicsrd.csrd.uiuc.edu> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 14 In article <44200016@uicsrd.csrd.uiuc.edu> mcdaniel@uicsrd.csrd.uiuc.edu writes: >One possible >macro implementation is: > #define iscntrl(c) ( (c) >= 0 && (c) <= 037 ) > >(The first test is because implementations are permitted by dpANS to >have signed characters.) In this case, if "c" has side effects, the >side effects will be performed twice. A reasonably well-known hack, where L and U are constant integer expressions, is #define inrange(x,L,U) ((unsigned)((x)-(L)) <= (unsigned)((U)-(L))) It has the virtue that x is evaluated only once. In this case: *define iscntrl(c) ((unsigned)(c) < 32) I say "*define" because the usual definition of iscntrl() for ASCII includes DEL as one of the cntrl characters.