why would std::string s("??<") output a { instead of ??< as expected?
std::string s("??<");
std::cout << s << std::endl;
Why does that output { instead of ??<
I'm using Visual Studio 2008. I'm assume it's encoding it but why and what is the encoding called if that is what's happe开发者_Python百科ning?
This little %#$^*! caused me to look for a bug in my (unit test) code for 30 minutes before I figured out my string was mangled!! :(
Because of trigraphs.
These are the supported trigraphs, from the Wikipedia page:
??=
→#
??/
→\
??'
→^
??(
→[
??)
→]
??!
→|
??<
→{
??>
→}
??-
→~
For Visual Studio, according to the documentation trigraphs are turned off by default (sensibly enough), so check your project/makefiles.
精彩评论