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

QTextStream reading from UTF-8 file fails midway

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Invalid
    • Affects Version/s: 5.14
    • Fix Version/s: None
    • Labels:
    • Environment:
      Fedora 32, x86_64
    • Platform/s:
      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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            thiago Thiago Macieira
            Reporter:
            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