Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-89009

QTextStream reading from UTF-8 file fails midway

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.14
    • Fedora 32, x86_64
    • Linux/X11

    Description

      Reading line by line from a UTF-8 file using QTextStream in a loop till QFile::atEnd(), seems to stop midway. I have attached a simple test program and input file to recreate the problem. The program simply reads the file line by line and increments a line number variable. Finally, outside the loop, the line number is printed. It is found to be much less than the total lines in the file.

      I spotted the problem when I was trying to read a UTF-8 file, filter out some lines and write the rest to another file. There are very weird observations such as difference in outputs with and without explicit calls to QFile::close() just before returning from main().

      Attachments

        1. problem_demo.tar.gz
          110 kB
          Syam Krishnan
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            syam.krishnan Syam Krishnan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes