先试试 wchar_t 打印到 Windows 控制台。locale你大爷的。然后用 bitset 把二进制位打印出来谢罪。
于是,Unicode 查询器?(笑)
1 #include <iostream> 2 #include <string> 3 #include <fstream> 4 #include <locale> 5 #include <bitset> 6 7 int main(int argc, char *argv[]) 8 { 9 std::locale mylocale("zh-CN"); 10 11 std::wcout.imbue(mylocale); 12 13 std::wstring str(L"世界第一可爱的literal酱!"); 14 std::wcout << str << std::endl; 15 16 std::bitset<sizeof(wchar_t) * 8> bs; 17 unsigned count = 0; 18 for (wchar_t wc : str) 19 { 20 bs = wc; 21 printf("str+%2d -> %04x\n", count++, bs.to_ullong()); 22 } 23 }