[Interest] QTextStream problem

Turtle Creek Software support at turtlesoft.com
Wed Jul 31 14:16:49 CEST 2024


The data files may have any of 3 possible line endings, depending on
whether they were made on Windows or old/new Macs.  The one we tested with
must have been created on an older Mac with just CR.

Seems to me that QTextStream::readAll should read all the text, like the
name says. Let the user process line endings.  Ditto for
QTextStream::read.  Actually readLine also breaks, because CRs are stripped
before it parses lines.

If existing users rely on CR-zapping, then at least add a mention in the
docs and/or a way to control it.

Best, Casey McD

On Wed, Jul 31, 2024 at 6:00 AM <interest-request at qt-project.org> wrote:

> Send Interest mailing list submissions to
>         interest at qt-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.qt-project.org/listinfo/interest
> or, via email, send a message with subject or body 'help' to
>         interest-request at qt-project.org
>
> You can reach the person managing the list at
>         interest-owner at qt-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Interest digest..."
> Today's Topics:
>
>    1. QTextStream problem (Turtle Creek Software)
>    2. Re: QTextStream problem (Thiago Macieira)
>
>
>
> ---------- Forwarded message ----------
> From: Turtle Creek Software <support at turtlesoft.com>
> To: interest at qt-project.org
> Cc:
> Bcc:
> Date: Tue, 30 Jul 2024 11:30:27 -0400
> Subject: [Interest] QTextStream problem
> 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.
>
> Casey McDermott
> TurtleSoft.com
>
>
>
>
>
> ---------- Forwarded message ----------
> From: Thiago Macieira <thiago.macieira at intel.com>
> To: interest at qt-project.org
> Cc:
> Bcc:
> Date: Tue, 30 Jul 2024 08:57:48 -0700
> Subject: Re: [Interest] QTextStream problem
> 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
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240731/ba550fdb/attachment.htm>


More information about the Interest mailing list