I'm trying to read lines from .txt files, that have been saved as Unicode. That's how i'm doing it:
wifstream input;
string path = "test.txt";
input.imbue(locale(input.getloc(),
new codecvt_utf16<wchar_t, 0x10ffff, consume_header>));
input.open(path);
if (input.is_open())
{
wstring line;
input.seekg( 1 , ios_base::beg);
getline(input, line);
}
It works fine for files with Latin characters. But for Cyrillic files I get weird symbols instead of spaces and adjacent characters.
For example:
What is in the input file:
Госдеп США осудил нападение на
What I get:
︓осдепР!ШАР>судилР=ападениеР=а
What am I doing wrong?