print ‘Ø’ and ‘𦍏’ in c++?

huangapple go评论121阅读模式
英文:

print 'Ø' and '𐌟' in c++?

问题

我尝试使用 wchar_t,但它会产生警告并在终端中打印奇怪的字符。\n直接打印会得到相同的结果\n\n cout<<Ø<< <<𐌟;\n\n输出:\n\n ├ÿ ≡Éîƒ

英文:

I tried using wchar_t but it gave a warning and print weird characters in the terminal.
or printing directly gave the same result

cout&lt;&lt;&quot;&#216;&quot;&lt;&lt;&quot;  &quot;&lt;&lt;&quot;&#66335;&quot;;

gives output:

├&#255;  ≡&#201;&#238;ƒ

答案1

得分: 2

#include <string>
#include <iostream>
#include <Windows.h>
#include <cstdio>

int main(){
    SetConsoleOutputCP(CP_UTF8);
    setvbuf(stdout, nullptr, _IOFBF, 1000);
    std::cout << "Ø" << "  " << "極";
}
英文:
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;Windows.h&gt;
#include &lt;cstdio&gt;


int main(){
// Set console code page to UTF-8 so console known how to interpret string data
    SetConsoleOutputCP(CP_UTF8);

// Enable buffering to prevent VS from chopping up UTF-8 byte sequences
    setvbuf(stdout, nullptr, _IOFBF, 1000);

    std::cout&lt;&lt;&quot;&#216;&quot;&lt;&lt;&quot;  &quot;&lt;&lt;&quot;&#66335;&quot;;
}

I got the answer, It prints the value as expected

huangapple
  • 本文由 发表于 2023年6月8日 00:55:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76425549.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定