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

QFile::readLine handles linefeeds incorrectly if file has Utf16-LE encoding

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.15.4, 6.6.0
    • Core: I/O
    • None
    • VS2019 x64

    Description

      QFile::readLine() handles Linefeeds incorrectly, if the read file has Utf16-LE (Little Endian) format.

      In UTF-16-LE, linefeeds are encoded as "0x0a 0x00", but "readLine" seems to cut off the second byte. So the line ends with "0x0a" and the next starts with "0x00", which is incorrect behavior and may lead to consequential errors. (see my example).

      Other encodings (UTF-8, UTF-16-BE, Single-Byte) seem to be handled correctly.

      Info: the test program was written for Qt6.6.0

      Attachments

        1. main.cpp
          2 kB
        2. test_utf16_le.txt
          0.1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            tneuhofer Thomas Neuhofer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes