We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
... or a misunderstanding on my part ?
From string "\x0CTUV", the compiler generates 0x0C 0x55 0x56 0x57 0x00
From string "\x0CABC", the compiler generates 0xCA 0x42 0x43 0x00 ... rather than the expected 0x0C 0x41 0x42 0x43 0x00
I thought the \x escape sequence in a string instructed the compiler to encode the very next two characters as a hexadecimal byte.
Am I missing something ?
From the above, it could be "assumed" that the Keil compiler is buggy and should have consumed all characters. But note point 9: The value of an octal or hexadecimal escape sequence shall be in the range of representable values for the type unsigned char for an integer character constant, or the unsigned type corresponding to wchar_t for a wide character constant.
So perhaps the compiler's logic in this matter is, "consume all characters up to, but not beyond the range of an unsigned char".
I guess I can live with that and I agree that no assumptions should be made in this area with different compilers.
I appreciate the feedback.
The point is that you should not concern yourself with the compiler's logic - you should concern yourself with ensuring that your source text is completely unambiguous and, therefore, not subject to any misinterpretation by any compiler logic!