Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QXmlStreamReader Codec
Forum Updated to NodeBB v4.3 + New Features

QXmlStreamReader Codec

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 804 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by VRonin
    #1

    Noob question here:
    Does QXmlStreamReader auto detect the text codec based on the start document (<?xml version="1.0" encoding="UTF-8"?>)? I noticed there is no setCodec method while QXmlStreamWriter has it so I want to make 100% sure it's dealt with automatically.

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Yes, the codec is automatically set depending on the encoding attribute if QT_NO_TEXTCODEC is not defined. See qxmlstream.cpp:

      #ifdef QT_NO_TEXTCODEC
                      readBuffer = QString::fromLatin1(rawReadBuffer.data(), nbytesread);
      #else
                      QTextCodec *const newCodec = QTextCodec::codecForName(name.toLatin1());
                      if (!newCodec)
                          err = QXmlStream::tr("Encoding %1 is unsupported").arg(name);
                      else if (newCodec != codec && !lockEncoding) {
                          codec = newCodec;
                          delete decoder;
                          decoder = codec->makeDecoder();
                          decoder->toUnicode(&readBuffer, rawReadBuffer.data(), nbytesread);
                      }
      #endif // QT_NO_TEXTCODEC
      
      1 Reply Last reply
      5

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved