summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs/qutfcodec.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-05-06 11:08:54 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-05-12 07:43:59 +0200
commite9005608eaf40a875b03e2c0513ee2b1e3675fd8 (patch)
tree82242fad71fee0f6dbe421ae720e835f578fd1ed /src/corelib/codecs/qutfcodec.cpp
parent1a8916cc4f55b70009a50e6fc69a49f32fc02720 (diff)
QtCore: use new QChar::fromUcs{2,4}()
Also replace one case of QChar(0) with QChar::Null. These were errors in my local tree, which means they're included in bootstrap builds (incl. qmake). Change-Id: I3dffa9383fd1a30aa43fe2491ad95bb2b1869b40 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/codecs/qutfcodec.cpp')
-rw-r--r--src/corelib/codecs/qutfcodec.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index 9419ce8d84..a31bfbd218 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -821,7 +821,7 @@ QString QUtf16::convertToUnicode(const char *chars, int len, QTextCodec::Convert
endian = BigEndianness;
} else {
endian = LittleEndianness;
- ch = QChar((ch.unicode() >> 8) | ((ch.unicode() & 0xff) << 8));
+ ch = QChar::fromUcs2((ch.unicode() >> 8) | ((ch.unicode() & 0xff) << 8));
}
*qch++ = ch;
}
@@ -951,12 +951,8 @@ QString QUtf32::convertToUnicode(const char *chars, int len, QTextCodec::Convert
}
}
uint code = (endian == BigEndianness) ? qFromBigEndian<quint32>(tuple) : qFromLittleEndian<quint32>(tuple);
- if (QChar::requiresSurrogates(code)) {
- *qch++ = QChar(QChar::highSurrogate(code));
- *qch++ = QChar(QChar::lowSurrogate(code));
- } else {
- *qch++ = QChar(code);
- }
+ for (char16_t c : QChar::fromUcs4(code))
+ *qch++ = c;
num = 0;
}
}