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

QXmlStreamReader::characterOffset() returns the wrong value for the first tag when the encoding is not UTF-8

    XMLWordPrintable

Details

    Description

      QXmlStreamReader::characterOffset() returns the wrong value for the first tag when the encoding is not UTF-8


      Can be reproduced using:

      #include <QXmlStreamReader> 
      #include <QDebug> 
       
      int main() 
      { 
              // If you uncomment the <?xml> header characterOffset() works as expected 
              const char data[] = //"<?xml version='1.0' encoding='UTF-8'?>" 
                                                      "<Tag1 attribute='X'><Tag2><Tag3>Y</Tag3></Tag2></Tag1>"; 
       
              QXmlStreamReader xml(data); 
              int offset=0; 
              while(!xml.atEnd()) 
              { 
                      xml.readNext(); 
                      if(xml.isStartElement()) 
                      { 
                              qDebug() << data; 
                              qDebug() << (QByteArray(offset, ' ')+"^").constData(); 
                      } 
                      offset=xml.characterOffset(); 
              } 
      }
      

      Attachments

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

        Activity

          People

            docteam Qt Documentation Team
            anshaw Andy Shaw (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes