我正在编写一个必须与字符↓
,→
和¬
一起使用的程序。我在阅读和打印字符时遇到麻烦。这很好用:
#include <iostream>
#include <string>
#include <io.h>
#include <fcntl.h>
using namespace std;
int main()
{
_setmode(_fileno(stdout), _O_U16TEXT);
wstring func = L"x→y";
wcout << func;
}
虽然这不是:#include <iostream>
#include <string>
#include <io.h>
#include <fcntl.h>
using namespace std;
int main()
{
_setmode(_fileno(stdout), _O_U16TEXT);
wstring func;
wcin >> func;
wcout << func;
}
不同的输入存在不同的问题。例如,对于输入的x↓y
,输出为x[?]y
,并且如果字符串包含→
,则由于某种原因我仍然必须在按Enter键之后输入一些内容,然后丢弃第一行中→
之后的所有内容。所以对于输入x→y
stuff
输出为x[?]stuff
。很高兴理解→
为何会发生奇怪的事情,并且/或者在保持输入和输出方面获得了一些解决方案。我正在使用Windows 10。
最佳答案
那么标准输入的编码呢?
在某些情况下,您不能输入特殊符号。
关于c++ - 无法读取包含→的wstrings并打印输入的unicode字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63301740/