Hexadecimal Escape Sequence

Doug Gwyn gwyn at smoke.BRL.MIL
Tue Jan 16 22:25:04 AEST 1990


In article <1335 at cybaswan.UUCP> iiitsh at cybaswan.UUCP (Steve Hosgood) writes:
>	printf("\x1bfred");	/* i.e "<ESC>fred" */
>... It seems that an infinite number of hex characters may follow the
>\x sequence, though what happens if the result fails to fit in a char is
>undefined.
>Is this what you'd call "expected behaviour"?

It's what I would expect.  Two hex digits is not always enough.

>After all, the octal escape sequence limits itself to 3 characters...

That's a deficiency in the octal escape sequence design that we were
able to remedy for the newly invented hex sequences.

>If it IS correct, how do you write "<ESC>fred" using a hex escape?

The simplest method is to use string concatenation:
	printf("\x1b""fred");



More information about the Comp.std.c mailing list