简体   繁体   中英

Print unicode in windows console

I'm trying to print Unicode symbol in console window using c++ here is my code

_setmode(_fileno(stdout), _O_U16TEXT);
std::wcout  << L"\u2B24"; 

Strange thing is, this code giving correct output for some Unicodes and not (it prints question mark instead of character) for some. I cannot figure-out why. as example works for this (\؟) and not works for this (\⬤)

Any Idea what I'm missing?

Edit:

Code: std::wcout << L"Test-"<<L"\؟"<< L"-Test" << std::endl;

Output: Test-?-Test

This can depend on the font that's configured to be used by the console window. If the font being used doesn't have the Unicode entry you're referencing, it won't display it. You can check which font you're using in the Properties of the command window. Then open up that font in the Character Map application that MS provide, and you can check which codes are available.

As an aside, you can add fonts to the Console window . However you probably need to bear in mind that someone else running your software may not have the same font configured as you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM