I need to read the file. The problem is that when using

QString helpfulStr = File.readLine(); 

instead of Russian letters is considered krakozyraba, and when using

  QTextStream textStream(&file); QString helpfulStr = textStream.readLine(); 

lost the transition to a new line in the file. And subsequent

  helpfulStr = textStream.readLine(); 

will return the void.

  • one
    And this option will not work: QTextStream input (& file); input.setCodec ("UTF-8"); input.readLine (); - progzdeveloper
  • How to translate a new line? - Dark Dead Dragon
  • You can read all at once: QTextStream input (& file); input.setCodec ("UTF-8"); QString str = input.readAll (); - progzdeveloper
  • This option does not suit me. I need to read it line by line, since parsing the data will then be very problematic. - Dark Dead Dragon
  • QTextStream input (& file); input.setCodec ("UTF-8"); input.readLine (); does not fit - does not translate to a new line, instead of Russian letters krakozyabry. By default, as I understand it, the text stream itself finds the desired codec. - Dark Dead Dragon

1 answer 1

In general, this is the case: when opening a text stream, the cursor in the readable file goes to the end. I passed the link to the open file to the function, created a stream in the functions and therefore the subsequent lines from other functions did not open. Solution: create a stream when opening a file, pass the stream itself into functions.