简体   繁体   English

如何将 ಠ 符号添加到我的 C++ 输出中

[英]How can I add a ಠ symbol into my C++ output

I am writing a program for school, and want to include an Easter Egg with the look of disapproval (ಠ_ಠ), however, I do not know what classes in C++ support this character.我正在为学校编写一个程序,并希望包含一个看起来不赞成(ಠ_ಠ)的复活节彩蛋,但是,我不知道 C++ 中的哪些类支持这个字符。 I would assume this character be included in unicode, but I am not sure how to use that to output into a console application.我假设这个字符包含在 unicode 中,但我不确定如何使用它来输出到控制台应用程序中。

If anyone could help me out with this, I would appreciate it.如果有人能帮我解决这个问题,我将不胜感激。 Thanks谢谢

Well you need to enable Unicode for your application.那么您需要为您的应用程序启用 Unicode。 For MSVC you can use _setmode(_fileno(stdout), _O_U16TEXT);对于 MSVC,您可以使用 _setmode(_fileno(stdout), _O_U16TEXT); at the start of your main.在你的主要开始时。 But for mingw this is a bit more difficult, see here .但是对于 mingw 这有点困难,请参阅 此处

To actually print it you can use the character code and use wcout but be wary!要实际打印它,您可以使用字符代码并使用 wcout 但要小心!

From: http://www.cplusplus.com/reference/iostream/cout/来自: http : //www.cplusplus.com/reference/iostream/cout/

A program should not mix output operations on cout with output operations on wcout (or with other wide-oriented output operations on stdout): Once an output operation has been performed on either, the standard output stream acquires an orientation (either narrow or wide) that can only be safely changed by calling freopen on stdout.程序不应将 cout 上的输出操作与 wcout 上的输出操作(或与 stdout 上的其他面向宽的输出操作)混合在一起:一旦对其中任何一个执行了输出操作,标准输出流就会获得一个方向(窄或宽)只能通过在 stdout 上调用 freopen 来安全地更改。

You can use \ಠ , that's the Unicode code for this eye thing.你可以使用\ಠ ,这是这个眼睛的Unicode代码。 Here's a live example:这是一个活生生的例子:

int main() {
    cout << "hi \u0CA0_\u0CA0";
    return 0;
}

https://ideone.com/QBFtsM https://ideone.com/QBFtsM

Although IDEOne supports unicode (as in, I can just paste ) so I'm not sure if that will work for you.尽管 IDEOne 支持 unicode(例如,我可以粘贴 ),所以我不确定这是否适合您。 Let me know.让我知道。

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

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