c++, cout and UTF-8

后端 未结 4 521
萌比男神i
萌比男神i 2020-12-19 03:44

Hopefully a simple question: cout seems to die when handling strings that end with a multibyte UTF-8 char, am I doing something wrong? This is with GCC (Mingw)

4条回答
  •  太阳男子
    2020-12-19 04:41

    As others have pointed out, std::cout is agnostic about this, at least in "C" locale (the default). On the other hand, your console window must be set up to display UTF-8: code page 65001. Try invoking chcp 65001 before executing your program. (This has worked for me in the past.)

提交回复
热议问题