[Interest] QWebSocket text methods should be utf8?

Jason H jhihn at gmx.com
Mon Feb 17 06:47:33 CET 2020

Thank you Thiago. This brings up an interesting question, for me at least. What else did you have in mind for the patch?

Given the potential large cost of creating a QString from a potentially large QByteArray to just emit it to no one, would it be possible to check to see if anyone is connected to the signal, before doing the QString conversion and emit?

> Sent: Friday, February 14, 2020 at 3:54 PM
> From: "Thiago Macieira" <thiago.macieira at intel.com>
> To: "interestqt-project.org" <interest at qt-project.org>
> Cc: "Jason H" <jhihn at gmx.com>
> Subject: Re: [Interest] QWebSocket text methods should be utf8?
> On Friday, 14 February 2020 11:13:24 PST Jason H wrote:
> > After reviewing the QWebSocket spec ( https://tools.ietf.org/html/rfc6455 )
> > text frames are supposed to be UTF-8 encoded, which would mean that
> > QByteArray would be the proper class.
> No, QString is the proper class because it's *text*. QWebSocket will convert
> from UTF-8 to UTF-16 and back for you.
> > Now I'm having to toUtf8() all the things I receive, and QString() the ones
> > I send. I am sure this leads to some degree of madness. I'm wondering if it
> > would be possible to provide proper overloads:
> > - sendTextMessage(const QByteArray &message)
> > - textMessageReceived(const QByteArray &message)
> > - textFrameReceived(const QByteArray &frame, bool isLastFrame)
> https://codereview.qt-project.org/c/qt/qtwebsockets/+/268194
> Feel free to pick up where I left off. I have absolutely no interest in web
> sockets so will not work on this.
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel System Software Products

More information about the Interest mailing list