_O_WTEXT, _O_U16TEXT, _O_U8TEXT - are these modes possible in mingw compiler, are there any workarounds?

后端 未结 2 1427
情书的邮戳
情书的邮戳 2020-12-10 17:02
#include 
#include 
#include 

int main(void) {
  _setmode(_fileno(stdout), _O_U16TEXT);
  wprintf(L\"\\x043a\\x043e\\x0448         


        
2条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 17:46

    Don't even bother with it.

    Your user needs to set the font of his console to a unicode one (Lucida Console for example), or else it won't display anything. If you're targeting East Asia, where the default font is unicode aware, it'll display fine, but in Europe, you have to change the font manually.

    User's won't change their console font because you write it in the readme. They won't even read the readme, they'll just see that it displays garbage, and they will think the program doesn't work.

    Also, it's a farly new function VS 2005, so you need to link the VS 2005 redistributeable, msvcr50.dll, or newer (mingw link to msvcrt.dll by default). If you don't do this, the text, won't be displayed at all.

    And I think a simple pipe will kill your new and shiny unicode text. Let's say your exe named a.exe. I'm pretty sure, that a.exe | more will NOT display unicode text.

提交回复
热议问题