With MSVC 2010 i try to compile this in C or C++ mode (needs to be compilable in both) and
it does not work. Why? I thought and found in the documentation that ‘\x’ takes the next two characters as hex characters and not more (4 characters when using \X”).
I also learned that there is no portable way to use character codes outside ASCII in C source code anyway, so how can i specify some german ISO-8859-1 characters?
int main() {
char* x = "\xBCd"; // Why is this not char(188) + 'd'
}
// returns test.c(2) : error C2022: '3021' : too big for character
// and a warning with GCC
Unfortunately you’ve stumbled upon the fact that
\xwill read every last character that appears to be hex1,2, instead you’ll need to break this up:Consider the output from this program:
Compiled and executed: