Newsgroups: comp.std.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Hexadecimal Escape Sequence Message-ID: <1990Jan16.194556.6727@utzoo.uucp> Organization: U of Toronto Zoology References: <1335@cybaswan.UUCP> <11960@smoke.BRL.MIL> Date: Tue, 16 Jan 90 19:45:56 GMT In article <11960@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >... Two hex digits is not always enough. Admittedly a problem... >>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. Introducing, in return, a new deficiency: the inability to terminate the hex sequence simply and cleanly when desired. Don't think this wasn't pointed out during the public reviews, by me among others. Among other things, it is a violation of the "prior art" rule, since prior experience (C++ and some C compilers) has been entirely (I think) with limited-length versions. >>If it IS correct, how do you write "fred" using a hex escape? >The simplest method is to use string concatenation: > printf("\x1b""fred"); As the man said, "there's *got* to be a better way". Unfortunately, none made it into the standard. Using string concatenation for this is an ugly kludge, not a proper solution. The right way would have been to include some sort of bracketing as part of the escape, e.g. "\x(ab)". This would even have allowed compatibility with C++ and other prior art: length is unlimited only within brackets, with plain "\xabc" being limited to three digits like the octal escapes. Alas, it's too late now. I expect the result will be widespread aversion to the error-prone context-sensitive hex escapes, defeating the original purpose of making life easier. -- 1972: Saturn V #15 flight-ready| Henry Spencer at U of Toronto Zoology 1990: birds nesting in engines | uunet!attcan!utzoo!henry henry@zoo.toronto.edu