'??' converts to '^' in Visual C ++. Why is this happening and what is the way out?
Are you sure it was a double quote and not a single quote? If it was? "Then you just met trigraph , which is a" feature "that really needs to be removed, but not because IBM didn't migrate to UTF-8 from EBCDIC . (Trigraphs were considered for removal when C ++ 0x was still open to change, but the move to remove trigraphs was violently blocked by IBM and its representatives on the ISO C ++ committee).
a source to share
Usually the sequence ??
starts the trigraph, but the "??" is not a trigraph so it cannot be interpreted as such - maybe there is a bug in the compiler - exactly which version you are using and what is the exact code (including variable declarations)?
This code prints "??" in multiple versions of MSVC 6 prior to VS 2010, as you might expect:
char ch[20];
sprintf( ch, "??");
printf( "%s\n", ch);
But replace the line snprintf()
with:
sprintf( ch, "'??'");
and the output becomes " '^
" (except VS 2010).
A quick test shows that VS 2010 disables trigraph support by default (it outputs " '??'
" in the second test). In VS 2010, you must explicitly enable trigraph support using the option /Zc:trigraphs
. Nice.
For more on what trigraphs are, see: Assigning Trigraph Sequences in C ++?
a source to share