Search code examples
c++visual-studio-2015utf-8cyrilliccfile

C++ Can't read UTF-8 cyrillic text from file


The file is UTF-8 (65001) encoded. I can't read cyrillic symbols from it.

CString FNAME;
CStdiofile fNFR;

fNFR.Open(_T("LFS200.25"), CFile::modeRead);
fNFR.ReadString(FNAME);

And got this:

 Зимний максимум 1989/90 гг.

instead of this:

 Зимний максимум 1989/90 гг.

Tried

setlocale(LC_ALL, "Rus");

Still the same problem.

How to get proper string?


Solution

  • I found the answer here (need to convert utf-8 to utf-16):

    CONVERSION BETWEEN UNICODE UTF-16 AND UTF-8 IN C++/WIN32