Special character constants
Henry Spencer
henry at zoo.toronto.edu
Thu Jan 17 04:42:48 AEST 1991
In article <1292 at mti.mti.com> adrian at mti.UUCP (Adrian McCarthy) writes:
>...On a machine whose character set does
>not support special characters like tab and backspace, what happens to
>character constants like '\t' and '\b'? Is there some special value they
>get set to (e.g., ' ' or '\0') instead? Or is this issue left undefined?
They must have *some value* distinct from each other and from printable
characters. In general, I think you are confusing the character set with
the output devices. An ASCII tab character is still a tab character even
if a particular output device does not do anything useful with it. Almost
every modern machine uses ASCII or some variant thereon, so the characters
almost invariably exist in the character set.
>I'd like to keep some code I'm writing portable to many machines by using
>tabs if they are available and emulating them with spaces if they are not.
Bear in mind that the definition of what an output device *does* with a
tab is very device-dependent. Just having tabs "available" is not enough;
you need to know exactly how they are processed. Short of using a library
like termcap or curses, if you want precise output appearance without any
prior knowledge of hardware or software, you're going to have to use
spaces regardless.
--
If the Space Shuttle was the answer, | Henry Spencer at U of Toronto Zoology
what was the question? | henry at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list