Search code examples
c++console-applicationmultibyte

How to output multiple byte characters normally in c/c++ console application?


printf("%s\n", multibytestring);

By default the multi-byte characters will show up like ??? in console, how can I fix it?


Solution

  • I'm guessing Windows, and that you mean multi-byte characters and not wide characters.

    Make sure that _MBCS is defined. Try calling setlocale and then _setmbcp:

    setlocale(LC_ALL, "japanese");
    _setmbcp(_MB_CP_LOCALE);
    

    After that it should hopefully work fine.