It is necessary to read a string from the html file, and continue to do some actions, but the problem is that the string instead of Russian letters is read from the file garbage. With other files, everything was always fine. The problem, I think, is in the file. Tried to do

setlocale(LC_ALL, "UTF-8"); SetConsoleCP(1251); SetConsoleOutputCP(1251); 

Had tried

 setlocale(LC_ALL, "ru_RU.UTF-8"); setlocale(LC_ALL, "en_US.UTF-8"); 

Nothing helps. html file picked up by saving the page manually. There are no problems with other files, the problem is only with .html files. Clearly shows that garbage is displayed on the console and in the line

I read from the file like this:

 getline(FileStreamOut, ParseStr) 

How to make Russian characters normally recorded in a string?

  • one
    What types have FileStreamOut and ParseStr ? - acade
  • ifstream and string - Mattern
  • one
  • that is, you are trying to output the text in utf-8 encoding to the console via the API, which probably expects cp866 encoding, while for some reason you want to change the encoding for cp1251. Not surprisingly, edgebands are obtained. To display text in the console, you can use Unicode. Example - jfs

1 answer 1

Try to specify the UTF-8 encoding on the html page itself via the meta tag:

 <meta charset="UTF-8"> 
  • <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> already has this line, and manually writing something in the file is not an option - Mattern