summaryrefslogtreecommitdiffstats
path: root/src/corelib/xml/qxmlstream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/xml/qxmlstream.cpp')
-rw-r--r--src/corelib/xml/qxmlstream.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index df5f3711cc..3949d2c3ac 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -3025,10 +3025,14 @@ void QXmlStreamWriterPrivate::checkIfASCIICompatibleCodec()
{
#ifndef QT_NO_TEXTCODEC
Q_ASSERT(encoder);
- // assumes ASCII-compatibility for all 8-bit encodings
- QChar space = QLatin1Char(' ');
- const QByteArray bytes = encoder->fromUnicode(&space, 1);
- isCodecASCIICompatible = (bytes.count() == 1);
+ // test ASCII-compatibility using the letter 'a'
+ QChar letterA = QLatin1Char('a');
+ const QByteArray bytesA = encoder->fromUnicode(&letterA, 1);
+ const bool isCodecASCIICompatibleA = (bytesA.count() == 1) && (bytesA[0] == 0x61) ;
+ QChar letterLess = QLatin1Char('<');
+ const QByteArray bytesLess = encoder->fromUnicode(&letterLess, 1);
+ const bool isCodecASCIICompatibleLess = (bytesLess.count() == 1) && (bytesLess[0] == 0x3C) ;
+ isCodecASCIICompatible = isCodecASCIICompatibleA && isCodecASCIICompatibleLess ;
#else
isCodecASCIICompatible = true;
#endif