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

Get/send UTF-8 text messages in WebSockets

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • WebSockets
    • None

    Description

      A common use of WebSockets is the transmission of JSON messages as text messages. Text transmitted on WebSockets is UTF-8 (usually). QWebSocket only exposes signals/methods to get/send text frames/messages as a QString. This requires transcoding from/to UTF-16.
      In the case of JSON, this is (almost) always unnecessary, because most JSON parsers require the JSON to be in UTF-8 and JSON writers will usually write UTF-8 (QJsonValue for example). Thus, for parsing JSON, we'd do UTF-8 → UTF-16 → UTF-8 → parsed (backwards for writing).

      It would be great to have the ability to get the "raw" text payloads as a QByteArray (since there's no QUtf8String yet) and similarly to be able to send UTF-8 as a QByteArray or QUtf8String. This could be a switch on the WebSocket like ws->setTextAsUtf8(true) for the socket to emit text as UTF-8.

      Attachments

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

        Activity

          People

            cnn Qt Core & Network
            nerixyz Tom Fors
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes