[Interest] QTextStream problem

Thiago Macieira thiago.macieira at intel.com
Tue Jul 30 17:57:48 CEST 2024


On Tuesday 30 July 2024 08:30:27 GMT-7 Turtle Creek Software wrote:
> We ran into a weird error with QTextStream.  When using it to read a text
> file, it removes all the line endings. That happens with readAll, read and
> readLine.
> 
> Getting a QString direct from a QFile via readAll works properly.
> 
> Is this expected behavior in QTextStream? It's not documented anywhere.

No, it's not.

Looking at the code, it looks like it implements the translation from CRLF to 
newlines by simple removal of the CR. It doesn't check that it's followed by 
an LF.

Is your text file using CRs alone for line breaks?

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Principal Engineer - Intel DCAI Platform & System Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240730/8c1a7873/attachment.bin>


More information about the Interest mailing list