summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--src/corelib/codecs/qutfcodec.cpp10
-rw-r--r--src/corelib/kernel/qvariant.cpp4
-rw-r--r--src/corelib/serialization/qjsonparser.cpp7
-rw-r--r--src/corelib/text/qlocale.cpp2
4 files changed, 7 insertions, 16 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;
}
}
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 6d3c7b4831..c5cf6b9464 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -525,14 +525,14 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Short:
case QMetaType::Long:
case QMetaType::Float:
- *c = QChar(ushort(qMetaTypeNumber(d)));
+ *c = QChar::fromUcs2(qMetaTypeNumber(d));
break;
case QMetaType::UInt:
case QMetaType::ULongLong:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
- *c = QChar(ushort(qMetaTypeUNumber(d)));
+ *c = QChar::fromUcs2(qMetaTypeUNumber(d));
break;
default:
return false;
diff --git a/src/corelib/serialization/qjsonparser.cpp b/src/corelib/serialization/qjsonparser.cpp
index d7ce702ff7..46d82ea47f 100644
--- a/src/corelib/serialization/qjsonparser.cpp
+++ b/src/corelib/serialization/qjsonparser.cpp
@@ -922,12 +922,7 @@ bool Parser::parseString()
return false;
}
}
- if (QChar::requiresSurrogates(ch)) {
- ucs4.append(QChar::highSurrogate(ch));
- ucs4.append(QChar::lowSurrogate(ch));
- } else {
- ucs4.append(QChar(ushort(ch)));
- }
+ ucs4.append(QChar::fromUcs4(ch));
}
++json;
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 8df28797bd..c57dc042d3 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -3897,7 +3897,7 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o
char out = numericToCLocale(in);
if (out == 0) {
- const QChar simple(in.size() == 1 ? in.front() : QChar(0));
+ const QChar simple = in.size() == 1 ? in.front() : QChar::Null;
if (in == listSeparator())
out = ';';
else if (in == percentSign())