使用Unicode C++的飞机符号

Airplane symbol using Unicode C++

本文关键字:飞机 符号 C++ Unicode 使用      更新时间:2023-10-16

我正试图在我的代码块中使用Unicode打印飞机符号。我发现飞机的代码是u2708。所以我尝试了以下代码:

   #include <iostream>
using namespace std;
int main() {
    wchar_t a = 'u2708';
    cout << a;
return 0;
}

当我用字符替换wchar_t时,它输出40072

char a = 'u2708';

我得到这个符号:ł

我真的很困,谢谢你的帮助。

如果您在Linux中,并且不使用从unicode到控制台的代码页转换,请尝试以下操作:

std::locale::global(std::locale(""));
wchar_t plane = L'u2708';
std::wcout << plane << std::endl;

在windows中有点复杂,您需要在默认控制台上使用兼容的unicode字体和正确的代码页。