summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-07-03 14:13:15 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2020-07-17 12:19:01 +0200
commitd8538163075a2058f110bc77e7d481ef1ab7612c (patch)
tree81baa561bc27826b587ed220342a4a8602298400 /src/corelib/text/qlocale.cpp
parent51e3cd89a81abdbf2fb6c60054d418084e4474c4 (diff)
Fix handling of Suzhou numbering system
This only arises when the system locale tells us to use its zero as our zero digit, since no CLDR locale uses it by default. Adapt an MS-specific QLocale::system() test to use Suzhou numbering, so as to test this. While updating the locale-restoration code to also restore the digits being set in that test, add restore code for the long time format, where previously only the short time format was restored. Add a comment to make it less likely one of those shall be missed in future. Fixes: QTBUG-85409 Change-Id: I343324bb563ee0e455dfe77d4825bf8c3082ca30 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qlocale.cpp')
-rw-r--r--src/corelib/text/qlocale.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 5bf2f7b296..2febee62a9 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -3363,7 +3363,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 = zeroUcs4 - '0' + digits.at(i).unicode();
+ const uint digit = unicodeForDigit(digits.at(i).unicode() - '0', zeroUcs4);
Q_ASSERT(QChar::requiresSurrogates(digit));
converted.append(QChar::highSurrogate(digit));
converted.append(QChar::lowSurrogate(digit));
@@ -3372,9 +3372,10 @@ 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() - '0';
+ ushort z = zero.at(0).unicode();
+ ushort *const value = reinterpret_cast<ushort *>(digits.data());
for (int i = 0; i < digits.length(); ++i)
- reinterpret_cast<ushort *>(digits.data())[i] += z;
+ value[i] = unicodeForDigit(value[i] - '0', z);
}
const bool mustMarkDecimal = flags & ForcePoint;