diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-01-08 14:15:16 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-01-08 15:08:55 (GMT) |
commit | fdac6df6d46e6d4f00763365de5a4437ad06ba39 (patch) | |
tree | 74b26b3b9f65b6ba507528c73ac18d9740700a24 /src/corelib | |
parent | 7fb78e7f60ea72e9e471d6cbc4403d490581df17 (diff) | |
download | Qt-fdac6df6d46e6d4f00763365de5a4437ad06ba39.zip Qt-fdac6df6d46e6d4f00763365de5a4437ad06ba39.tar.gz Qt-fdac6df6d46e6d4f00763365de5a4437ad06ba39.tar.bz2 |
Use the new QTextCodec api in the QXmlStreamWriter.
Instead of accesing private data, use the QTextCodec::makeEncoder() to pass the
initial conversion flags to the codec.
Also improved the behavior - we shouldn't add BOM in the middle of the data
when dumping xml in all encodings, not only for utf8.
Task-number: QTBUG-7180
Reviewed-by: Thiago
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/codecs/qtextcodec.h | 5 | ||||
-rw-r--r-- | src/corelib/xml/qxmlstream.cpp | 7 |
2 files changed, 2 insertions, 10 deletions
diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h index 5012b42..e37527d 100644 --- a/src/corelib/codecs/qtextcodec.h +++ b/src/corelib/codecs/qtextcodec.h @@ -171,11 +171,6 @@ public: private: const QTextCodec *c; QTextCodec::ConverterState state; - - friend class QXmlStreamWriter; - friend class QXmlStreamWriterPrivate; - friend class QCoreXmlStreamWriter; - friend class QCoreXmlStreamWriterPrivate; }; class Q_CORE_EXPORT QTextDecoder { diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index 5717ca2..1bf00b8 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -3003,8 +3003,7 @@ QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q) deleteDevice = false; #ifndef QT_NO_TEXTCODEC codec = QTextCodec::codecForMib(106); // utf8 - encoder = codec->makeEncoder(); - encoder->state.flags |= QTextCodec::IgnoreHeader; // no byte order mark for utf8 + encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8 #endif inStartElement = inEmptyElement = false; wroteSomething = false; @@ -3278,9 +3277,7 @@ void QXmlStreamWriter::setCodec(QTextCodec *codec) if (codec) { d->codec = codec; delete d->encoder; - d->encoder = codec->makeEncoder(); - if (codec->mibEnum() == 106) - d->encoder->state.flags |= QTextCodec::IgnoreHeader; // no byte order mark for utf8 + d->encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8 } } |