C on IBM machines

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Sep 22 08:06:56 AEST 1990


In article <18089 at haddock.ima.isc.com> karl at kelp.ima.isc.com (Karl Heuer) writes:
>Ideally, yes.  Though if you inherit a bunch of ASCII-specific code, it may
>well turn out that the path of least resistance is to use an implementation
>that emulates ASCII via transliteration inside the I/O calls.

Or, the application could explicitly map between the native host character
set and ASCII.  I've found the following "functions" useful over the years:

/* integer (or character) arguments and value: */
#define fromhostc( c )	(c)		/* map host char set to ASCII */
#define tohostc( c )	(c)		/* map ASCII to host char set */

The definitions of these are, of course, tailored to the environment.
The above are the trivial versions when the native character set is
already ASCII.  In an EBCDIC environment they would index a translation
table (much like the typical implementation of the <ctype.h> macros).



More information about the Comp.std.c mailing list