How to Print Unicode Text to the Windows Console in C++ -- Giovanni Dicanio

Have you ever wondered how to correctly print Unicode text to the Windows console in your C++ programs? Maybe you tried something, and you got meaningless output, or even an assertion failure at runtime, pointing to some obscure code in the CRT? Well, then this article is for you!

How to Print Unicode Text to the Windows Console in C++

by Giovanni Dicanio

From the blog post:

Suppose that you want to print out some Unicode text to the Windows console. From a simple C++ console application created in Visual Studio, you may try this line of code inside main:

std::wcout << L"Japan written in Japanese: x65e5x672c (Nihon)n";

As you can see, the Japanese kanjis are not printed. Moreover, even the “standard ASCII” characters following those (i.e.: “(Nihon)”) are missing. There’s clearly a bug in the above code.

How can you fix that?

Well, the missing piece is ...

Add a Comment

You must sign in or register to add a comment.

Comments (0)

There are currently no comments on this entry.