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>
This commit is contained in:
Marc Mutz 2020-05-06 11:08:54 +02:00
parent 1a8916cc4f
commit e9005608ea
4 changed files with 7 additions and 16 deletions

View File

@ -821,7 +821,7 @@ QString QUtf16::convertToUnicode(const char *chars, int len, QTextCodec::Convert
endian = BigEndianness; endian = BigEndianness;
} else { } else {
endian = LittleEndianness; endian = LittleEndianness;
ch = QChar((ch.unicode() >> 8) | ((ch.unicode() & 0xff) << 8)); ch = QChar::fromUcs2((ch.unicode() >> 8) | ((ch.unicode() & 0xff) << 8));
} }
*qch++ = ch; *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); uint code = (endian == BigEndianness) ? qFromBigEndian<quint32>(tuple) : qFromLittleEndian<quint32>(tuple);
if (QChar::requiresSurrogates(code)) { for (char16_t c : QChar::fromUcs4(code))
*qch++ = QChar(QChar::highSurrogate(code)); *qch++ = c;
*qch++ = QChar(QChar::lowSurrogate(code));
} else {
*qch++ = QChar(code);
}
num = 0; num = 0;
} }
} }

View File

@ -525,14 +525,14 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Short: case QMetaType::Short:
case QMetaType::Long: case QMetaType::Long:
case QMetaType::Float: case QMetaType::Float:
*c = QChar(ushort(qMetaTypeNumber(d))); *c = QChar::fromUcs2(qMetaTypeNumber(d));
break; break;
case QMetaType::UInt: case QMetaType::UInt:
case QMetaType::ULongLong: case QMetaType::ULongLong:
case QMetaType::UChar: case QMetaType::UChar:
case QMetaType::UShort: case QMetaType::UShort:
case QMetaType::ULong: case QMetaType::ULong:
*c = QChar(ushort(qMetaTypeUNumber(d))); *c = QChar::fromUcs2(qMetaTypeUNumber(d));
break; break;
default: default:
return false; return false;

View File

@ -922,12 +922,7 @@ bool Parser::parseString()
return false; return false;
} }
} }
if (QChar::requiresSurrogates(ch)) { ucs4.append(QChar::fromUcs4(ch));
ucs4.append(QChar::highSurrogate(ch));
ucs4.append(QChar::lowSurrogate(ch));
} else {
ucs4.append(QChar(ushort(ch)));
}
} }
++json; ++json;

View File

@ -3897,7 +3897,7 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o
char out = numericToCLocale(in); char out = numericToCLocale(in);
if (out == 0) { 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()) if (in == listSeparator())
out = ';'; out = ';';
else if (in == percentSign()) else if (in == percentSign())