summaryrefslogtreecommitdiffstats
path: root/src/xml/dom/qdom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xml/dom/qdom.cpp')
-rw-r--r--src/xml/dom/qdom.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index ba37374f75..45da7f961d 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -62,7 +62,7 @@
#include <qdebug.h>
#include <qxmlstream.h>
#include <private/qduplicatetracker_p.h>
-
+#include <private/qstringiterator_p.h>
#include <stdio.h>
#include <limits>
@@ -192,11 +192,26 @@ static QString fixedCharData(const QString &data, bool *ok)
return data;
}
+ // Copied from QChar::fromUcs4() implementation in Qt 6
+ auto fromUcs4 = [](char32_t c) noexcept {
+ struct R {
+ char16_t chars[2];
+ operator QStringView() const noexcept { return {begin(), end()}; }
+ qsizetype size() const noexcept { return chars[1] ? 2 : 1; }
+ const char16_t *begin() const noexcept { return chars; }
+ const char16_t *end() const noexcept { return begin() + size(); }
+ };
+ if (QChar::requiresSurrogates(c))
+ return R{{QChar::highSurrogate(c), QChar::lowSurrogate(c)}};
+ return R{{char16_t(c), u'\0'}};
+ };
+
QString result;
- for (int i = 0; i < data.size(); ++i) {
- QChar c = data.at(i);
+ QStringIterator it(data);
+ while (it.hasNext()) {
+ const char32_t c = it.next(QChar::Null);
if (QXmlUtils::isChar(c)) {
- result.append(c);
+ result.append(fromUcs4(c));
} else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
*ok = false;
return QString();
@@ -4491,7 +4506,7 @@ QString QDomElement::attributeNS(const QString nsURI, const QString& localName,
Adds an attribute with the qualified name \a qName and the
namespace URI \a nsURI with the value \a value. If an attribute
with the same local name and namespace URI exists, its prefix is
- replaced by the prefix of \a qName and its value is repaced by \a
+ replaced by the prefix of \a qName and its value is replaced by \a
value.
Although \a qName is the qualified name, the local name is used to
@@ -4714,7 +4729,7 @@ void QDomTextPrivate::save(QTextStream& s, int, int) const
\ingroup xml-tools
You can split the text in a QDomText object over two QDomText
- objecs with splitText().
+ objects with splitText().
For further information about the Document Object Model see
\l{http://www.w3.org/TR/REC-DOM-Level-1/}{Level 1} and