英文:
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<<"Ø"<<" "<<"𐌟";
gives output:
Ø 𐌟
答案1
得分: 2
#include <string>
#include <iostream>
#include <Windows.h>
#include <cstdio>
int main(){
SetConsoleOutputCP(CP_UTF8);
setvbuf(stdout, nullptr, _IOFBF, 1000);
std::cout << "Ø" << " " << "極";
}
英文:
#include <string>
#include <iostream>
#include <Windows.h>
#include <cstdio>
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<<"Ø"<<" "<<"𐌟";
}
I got the answer, It prints the value as expected
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论