[comp.lang.c] Implementations of char manipulation macros

g-rh@XAIT.Xerox.COM (Richard Harter) (10/21/88)

In article <7594@bloom-beacon.MIT.EDU> scs@adam.pika.mit.edu (Steve Summit) writes:

	... long amusing article on character manipulation macros ...

	----

	Having been burnt a few times on various such implementations
I ended up coding them myself using tables (a caveat being that I usually
am in a situation where speed is more important than memory).  I.e. the
relevant macro is something like

#define mytoupper(c) casemap[(c)&0xff]

where casemap is an array of 256 chars with the lowers mapping to uppers
and the rest mapping to themselves.  It is not, perhaps, a terribly
elegant approach, but it works and it doesn't leave you at the mercy of
surprises in system routine implementations.
-- 

In the fields of Hell where the grass grows high
Are the graves of dreams allowed to die.
	Richard Harter, SMDS  Inc.