问问题
52 次
1 回答
1
L"á"
means the file was read with a wrong encoding. You have to imbue a UTF-8 locale before reading the stream.
wifstream input{argv[1]};
input.imbue(std::locale("en_US.UTF-8"));
wstring line;
getline(input, line);
Now wstring line
will contain Unicode code points (á
in your case) and can be easily iterated.
Caveat: on Windows wchar_t
is deficient (16-bit), and is good enough for iterating over BMP only.
于 2020-06-22T21:50:10.650 回答