小编Elt*_*ets的帖子

std::wcout 打印 unicode 字符但它们被隐藏

所以,下面的代码:

\n
#include <iostream>\n#include <string>\n#include <io.h>\n#include <fcntl.h>\n#include <codecvt>\n\nint main()\n{\n    setlocale(LC_ALL, "");\n\n    std::wstring a;\n    std::wcout << L"Type a string: " << std::endl;\n    std::getline(std::wcin, a);\n    std::wcout << a << std::endl;\n    getchar();\n}\n
Run Code Online (Sandbox Code Playgroud)\n

当我输入“\xc3\xa5\xc3\xa4\xc3\xb6”时,我得到一些奇怪的输出。终端的光标是缩进的,但后面没有文本。如果我使用右箭头键向前移动光标,则当我单击右箭头键时,“\xc3\xa5\xc3\xa4\xc3\xb6”会显示出来。

\n

如果我包含英文字母,以便输入为“hello\xc3\xa5\xc3\xa4\xc3\xb6”,则输出为“hello”,但当我单击右箭头键“hello\xc3\xa5\xc3\xa4\”时xc3\xb6" 一个字母一个字母地出现。

\n

为什么会发生这种情况,更重要的是我该如何解决它?

\n

编辑:我在 Windows 上使用 Visual Studio 的编译器进行编译。当我在 repl.it 中尝试这个确切的代码(他们使用 clang)时,它就像一个魅力。问题是由我的代码、Windows 还是 Visual Studio 引起的吗?

\n

c++ unicode

3
推荐指数
1
解决办法
895
查看次数

标签 统计

c++ ×1

unicode ×1