diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 159cbc0944..152570bc84 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -103,9 +103,9 @@ QLocale::Language QLocalePrivate::codeToLanguage(QStringView code) noexcept const auto len = code.size(); if (len != 2 && len != 3) return QLocale::C; - ushort uc1 = code[0].toLower().unicode(); - ushort uc2 = code[1].toLower().unicode(); - ushort uc3 = len > 2 ? code[2].toLower().unicode() : 0; + char16_t uc1 = code[0].toLower().unicode(); + char16_t uc2 = code[1].toLower().unicode(); + char16_t uc3 = len > 2 ? code[2].toLower().unicode() : 0; const unsigned char *c = language_code_list; for (; *c != 0; c += 3) { @@ -168,9 +168,9 @@ QLocale::Country QLocalePrivate::codeToCountry(QStringView code) noexcept if (len != 2 && len != 3) return QLocale::AnyCountry; - ushort uc1 = code[0].toUpper().unicode(); - ushort uc2 = code[1].toUpper().unicode(); - ushort uc3 = len > 2 ? code[2].toUpper().unicode() : 0; + char16_t uc1 = code[0].toUpper().unicode(); + char16_t uc2 = code[1].toUpper().unicode(); + char16_t uc3 = len > 2 ? code[2].toUpper().unicode() : 0; const unsigned char *c = country_code_list; for (; *c != 0; c += 3) { @@ -879,7 +879,7 @@ QString QLocaleData::zeroDigit() const return zero().getData(single_character_data); } -uint QLocaleData::zeroUcs() const +char32_t QLocaleData::zeroUcs() const { #ifndef QT_NO_SYSTEMLOCALE if (this == systemData()) { @@ -3326,7 +3326,7 @@ QString QLocaleData::doubleToString(double d, int precision, DoubleForm form, QString converted; converted.reserve(2 * digits.size()); for (int i = 0; i < digits.length(); ++i) { - const uint digit = unicodeForDigit(digits.at(i).unicode() - '0', zeroUcs4); + const char32_t digit = unicodeForDigit(digits.at(i).unicode() - '0', zeroUcs4); Q_ASSERT(QChar::requiresSurrogates(digit)); converted.append(QChar::highSurrogate(digit)); converted.append(QChar::lowSurrogate(digit)); @@ -3335,8 +3335,8 @@ QString QLocaleData::doubleToString(double d, int precision, DoubleForm form, } else { Q_ASSERT(zero.size() == 1); Q_ASSERT(!zero.at(0).isSurrogate()); - ushort z = zero.at(0).unicode(); - ushort *const value = reinterpret_cast(digits.data()); + char16_t z = zero.at(0).unicode(); + char16_t *const value = reinterpret_cast(digits.data()); for (int i = 0; i < digits.length(); ++i) value[i] = unicodeForDigit(value[i] - '0', z); } diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h index df6aba30ce..56af6b0a38 100644 --- a/src/corelib/text/qlocale_p.h +++ b/src/corelib/text/qlocale_p.h @@ -282,7 +282,7 @@ public: QString listSeparator() const; QString percentSign() const; QString zeroDigit() const; - uint zeroUcs() const; + char32_t zeroUcs() const; QString positiveSign() const; QString negativeSign() const; QString exponentSeparator() const; @@ -309,7 +309,7 @@ public: { return listEntry(table, index).viewData(table); } - uint ucsFirst(const char16_t *table) const + char32_t ucsFirst(const char16_t *table) const { if (size && !QChar::isSurrogate(table[offset])) return table[offset]; @@ -462,21 +462,18 @@ inline char QLocaleData::numericToCLocale(QStringView in) const if ((group == u"\xa0" || group == u"\x202f") && in == u" ") return ','; - const uint inUcs4 = in.size() == 2 + const char32_t inUcs4 = in.size() == 2 ? QChar::surrogateToUcs4(in.at(0), in.at(1)) : in.at(0).unicode(); - const uint zeroUcs4 = zeroUcs(); + const char32_t zeroUcs4 = zeroUcs(); // Must match qlocale_tools.h's unicodeForDigit() - if (zeroUcs4 == 0x3007u) { + if (zeroUcs4 == u'\u3007') { // QTBUG-85409: Suzhou's digits aren't contiguous ! if (inUcs4 == zeroUcs4) return '0'; - if (inUcs4 > 0x3020u && inUcs4 <= 0x3029u) - return inUcs4 - 0x3020u; - } else { - const uint tenUcs4 = zeroUcs4 + 10; - - if (zeroUcs4 <= inUcs4 && inUcs4 < tenUcs4) - return '0' + inUcs4 - zeroUcs4; + if (inUcs4 > u'\u3020' && inUcs4 <= u'\u3029') + return inUcs4 - u'\u3020'; + } else if (zeroUcs4 <= inUcs4 && inUcs4 < zeroUcs4 + 10) { + return '0' + inUcs4 - zeroUcs4; } if ('0' <= inUcs4 && inUcs4 <= '9') return inUcs4; diff --git a/src/corelib/text/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp index cc34d3149a..cad2ce7353 100644 --- a/src/corelib/text/qlocale_tools.cpp +++ b/src/corelib/text/qlocale_tools.cpp @@ -461,8 +461,8 @@ QString qulltoa(qulonglong number, int base, const QStringView zero) // per digit. We do not need a terminator. const unsigned maxlen = 128; static_assert(CHAR_BIT * sizeof(number) <= maxlen); - ushort buff[maxlen]; - ushort *const end = buff + maxlen, *p = end; + char16_t buff[maxlen]; + char16_t *const end = buff + maxlen, *p = end; if (base != 10 || zero == u"0") { while (number != 0) { @@ -471,16 +471,16 @@ QString qulltoa(qulonglong number, int base, const QStringView zero) number /= base; } } else if (zero.size() && !zero.at(0).isSurrogate()) { - const ushort zeroUcs4 = zero.at(0).unicode(); + const char16_t zeroUcs2 = zero.at(0).unicode(); while (number != 0) { - *(--p) = unicodeForDigit(number % base, zeroUcs4); + *(--p) = unicodeForDigit(number % base, zeroUcs2); number /= base; } } else if (zero.size() == 2 && zero.at(0).isHighSurrogate()) { - const uint zeroUcs4 = QChar::surrogateToUcs4(zero.at(0), zero.at(1)); + const char32_t zeroUcs4 = QChar::surrogateToUcs4(zero.at(0), zero.at(1)); while (number != 0) { - const uint digit = unicodeForDigit(number % base, zeroUcs4); + const char32_t digit = unicodeForDigit(number % base, zeroUcs4); *(--p) = QChar::lowSurrogate(digit); *(--p) = QChar::highSurrogate(digit); diff --git a/src/corelib/text/qlocale_tools_p.h b/src/corelib/text/qlocale_tools_p.h index 723f27f3ee..e10408741e 100644 --- a/src/corelib/text/qlocale_tools_p.h +++ b/src/corelib/text/qlocale_tools_p.h @@ -100,8 +100,8 @@ inline UcsInt unicodeForDigit(uint digit, UcsInt zero) return zero; // See QTBUG-85409: Suzhou's digits are U+3007, U+2021, ..., U+3029 - if (zero == 0x3007u) - return 0x3020u + digit; + if (zero == u'\u3007') + return u'\u3020' + digit; // At CLDR 36.1, no other number system's digits were discontinuous. return zero + digit;