How to read Cyrillic Unicode file in C++?

醉酒当歌 提交于 2019-12-05 09:56:40

one line looks very suspicous in your code:

input.seekg(1, ios_base::beg);

it sets file position, so reading utf16 string starting position 1 might be incorrect (BOM is read incorrectly). i have the same result for utf16 file in little endian.

so you might change position to 0 or delete this line in order to make this code work

Well, figured out the way:

FILE *input= _wfopen(L"test.txt", L"rb");
wchar_t line[1000];
test.txtfgetws(line, 1000, input);

Works fine like that. Was quite stupid of me not to try it first. So thanks everyone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!