Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!reading!cf-cm!cybaswan!iiitsh From: iiitsh@cybaswan.UUCP (Steve Hosgood) Newsgroups: comp.std.c Subject: Hexadecimal Escape Sequence Summary: "\xabcdef" is a valid escape seq. Is this right? Message-ID: <1335@cybaswan.UUCP> Date: 15 Jan 90 11:32:03 GMT Reply-To: iiitsh@cybaswan.UUCP (Steve Hosgood) Organization: Institute for Industrial Information Technology Lines: 25 References: I recently discovered in K&R Edition 2 (ANSII C) that the hex escape sequence will accept any number of valid hex characters after the "\x". This means that the printf statement:- printf("\x1bfred"); /* i.e "fred" */ ..suddenly failed in a program when we updated from Microsoft 4.0 to 5.1 recently. According to K&R2, (my only reference), MSC5.1 interprets this correctly as "red", and 4.0 was wrong to limit itself to 2 hex chars following the \x. 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"? After all, the octal escape sequence limits itself to 3 characters... If it IS correct, how do you write "fred" using a hex escape? I ended up having to use the octal escape in the end, which seems rather an inelegant method. Thanks in advance for any insights. Steve