我正在用C++编写一个程序,它必须处理unicode字符。 主要的问题是我使用的算法,我需要通过焦炭解析我的S/wstrings 字符:使用wstring和wcout没有得到预期的输出
std::wstring word = L"Héllo"
for (auto &e : word)
// doing something with e
但是,如果我运行此:
std::wstring word = L"Héllo"
for (auto &e : word)
std::wcout << e << std::endl;
我得到这样的输出:
H
?
l
l
o
我做错了什么?
请注意,当使用std::wcout << word;
时,请正确打印word
。
编辑@Ben福格特
这里是出与std::wcout << std::hex << std::setw(4) << (int)e << L" " << e << L'\n';
:
48 H
e9 �
6c l
6c l
6f o
你呢r控制台支持unicode? – NathanOliver
观察:不处理代理对,因为未知字符只有一行输出。 –
它的确如此,因为当我打印std :: wcout中的所有字符串时,我可以看到'é' – LightMan