summaryrefslogtreecommitdiffstats
path: root/src/xml/dom/qdom.cpp
diff options
context:
space:
mode:
authorPeter Hartmann <peter.hartmann@nokia.com>2009-09-29 09:29:01 (GMT)
committerPeter Hartmann <peter.hartmann@nokia.com>2009-09-30 15:11:44 (GMT)
commit40909863e9eb17e0d0469ade608426dbbd08b43e (patch)
treeb90e8b120c774c296e9f5f01d5738666f37f4e5a /src/xml/dom/qdom.cpp
parent6fb1e687310f3f70c2f0bd3f25e91b65e65cafd2 (diff)
downloadQt-40909863e9eb17e0d0469ade608426dbbd08b43e.zip
Qt-40909863e9eb17e0d0469ade608426dbbd08b43e.tar.gz
Qt-40909863e9eb17e0d0469ade608426dbbd08b43e.tar.bz2
QDom: set the codec to UTF-8 if codec not present or unknown
we were trying to get a codec even for unknown names. Now, we always set the codec to UTF8 if the field is not present or we do not know the codec. Reviewed-by: Paul
Diffstat (limited to 'src/xml/dom/qdom.cpp')
-rw-r--r--src/xml/dom/qdom.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index 3ae91d3..b06fbeb 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -6438,22 +6438,23 @@ void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNod
#ifndef QT_NO_TEXTCODEC
const QDomNodePrivate* n = first;
+ QTextCodec *codec = 0;
+
if (n && n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml")) {
// we have an XML declaration
QString data = n->nodeValue();
QRegExp encoding(QString::fromLatin1("encoding\\s*=\\s*((\"([^\"]*)\")|('([^']*)'))"));
encoding.indexIn(data);
QString enc = encoding.cap(3);
- if (enc.isEmpty()) {
- enc = encoding.cap(5);
- }
if (enc.isEmpty())
- s.setCodec(QTextCodec::codecForName("UTF-8"));
- else
- s.setCodec(QTextCodec::codecForName(enc.toLatin1().data()));
- } else {
- s.setCodec(QTextCodec::codecForName("UTF-8"));
+ enc = encoding.cap(5);
+ if (!enc.isEmpty())
+ codec = QTextCodec::codecForName(enc.toLatin1().data());
}
+ if (!codec)
+ codec = QTextCodec::codecForName("UTF-8");
+ if (codec)
+ s.setCodec(codec);
#endif
bool doc = false;