简体   繁体   English

在Windows控制台中打印unicode

[英]Print unicode in windows console

I'm trying to print Unicode symbol in console window using c++ here is my code 我正在尝试使用c ++在控制台窗口中打印Unicode符号,这是我的代码

_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. 奇怪的是,这段代码为某些Unicode提供了正确的输出,而没有为某些代码提供(输出问号而不是字符)。 I cannot figure-out why. 我不知道为什么。 as example works for this (\؟) and not works for this (\⬤) 例如适用于此 (\\ u061F)而不适用于此 (\\ u2B24)

Any Idea what I'm missing? 知道我缺少什么吗?

Edit: 编辑:

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

Output: Test-?-Test 输出: 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. 如果所使用的字体没有您要引用的Unicode条目,它将不会显示它。 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. 然后在MS提供的“字符映射”应用程序中打开该字体,然后您可以检查可用的代码。

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. 但是,您可能需要记住,其他运行您的软件的人可能未配置与您相同的字体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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