I have a txt file (encoded in UTF-8) that contains the following text:
שלום עולם!
I tried to read the text and print it on the screen like this:
std::wifstream file("file.txt");
std::wstring line;
while (std::getline(file, line)) {
std::wcout << line << std::endl;
}
file.close();
But the output I get is:
╫⌐╫£╫ץ╫¥ ╫ó╫ץ╫£╫¥!
I tried:
- Using
ifstream,string,coutinstead ofwifstream,wstring,wcout. - Printing const hebrew string to the screen, resulting in me seeing the string properly:
_setmode(_fileno(stdout), 0x00040000);
std::wcout << L"שלום עולם!" << std::endl;
Resulting in:
שלום עולם!