It is impossible to read the text that includes the Cyrillic alphabet and output to the console from a file that has the encoding UTF8. The following code is available:
#include <iostream> #include <fstream> #include <string> #include <locale> #include <clocale> int main(int argc, wchar_t* argv[]) { std::wcout.imbue(std::locale("rus_rus.866")); std::wcin.imbue(std::locale("rus_rus.866")); std::wfstream fout; fout.open(L"cd.txt", std::ios::in); if (fout.is_open()) { fout.imbue(std::locale("rus_rus.1251")); wchar_t ch; std::wstring inputT; while (fout.get(ch)) inputT += ch; std::wcout << inputT; std::wcout << std::endl; fout.close(); } std::cin.get(); return 0; } And if the file being read is ANSI encoded, the entire text including Russian letters is displayed correctly, but if the file is in UTF8 encoding, then something is wrong. How can this be fixed?
fout.imbue(std::locale("rus_rus.1251"));, and the file you have in utf-8. - VladD