Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!seismo!sundc!netxcom!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c,net.micro.pc Subject: Re: Signed char - What Foolishness Is This! Message-ID: <606@hadron.UUCP> Date: Fri, 7-Nov-86 01:35:33 EST Article-I.D.: hadron.606 Posted: Fri Nov 7 01:35:33 1986 Date-Received: Sat, 8-Nov-86 07:02:17 EST References: <8719@duke.duke.UUCP> <228@apple.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 18 Xref: watmath net.lang.c:10921 net.micro.pc:11002 Summary: Suggestions for portable usage. In article <228@apple.UUCP> mikes@apple.UUCP (Mike Shannon) writes: >In <8719@duke.duke.UUCP> jwg@duke.UUCP (Jeffrey William Gillette) writes: >>MSC 4.0 defaults 'char' to 'signed char'. ... >> This works great when c = 65 ('A'), but when c = 154 >>('U'umlaut) the macro produces the following: ( (_ctype+1)[-102] & UPPER ) >> .... The standard (K&R, and now X3J11) has always held that 'char' is signed or unsigned, depending on the machine. For good, usable, portable code I've tended to do arithmetic ops (such as indexing an array) in shorts or ints, masking input chars. This is also great for testing EOF ... Also, the ctype macros should NOT be used with any char > 0177, simply because many or most current implementations only use a buffer that large. -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP} jsdy@hadron.COM (not yet domainised)