开发者

why would std::string s("??<") output a { instead of ??< as expected?

开发者 https://www.devze.com 2022-12-14 00:32 出处:网络
std::string s(\"??<\"); std::cout << s << std::endl; Why does that output { instead of ??<
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.

0

精彩评论

暂无评论...
验证码 换一张
取 消