Skip to content

Instantly share code, notes, and snippets.

@EmmanuelOga
Last active September 30, 2020 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EmmanuelOga/1f48bb73d70f17b3d970d464eea30cb6 to your computer and use it in GitHub Desktop.
Save EmmanuelOga/1f48bb73d70f17b3d970d464eea30cb6 to your computer and use it in GitHub Desktop.
State of the art in printing unicode characters to the console on Windows
#include <boost/nowide/iostream.hpp>
#include <boost/nowide/convert.hpp>
using namespace std;
namespace nw = boost::nowide;
int main()
{
string str{ "书中自有黄金屋\n" };
nw::cout << str;
}
@EmmanuelOga
Copy link
Author

EmmanuelOga commented Sep 30, 2020

Note: doesn't work on cmd.exe :-( (even with _set_mode). The only way I found was to change code page to 936 (chcp 936).
Windows terminal does behave in the expected way.

Good news! It seems like Windows Terminal (which doesn't exhibit the code page issue) may become the default terminal... by 2021...
microsoft/terminal#492 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment