summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale_tools_p.h
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_tools_p.h
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_tools_p.h')
-rw-r--r--src/corelib/text/qlocale_tools_p.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/corelib/text/qlocale_tools_p.h b/src/corelib/text/qlocale_tools_p.h
index e2e60b159d..17bfcb2e36 100644
--- a/src/corelib/text/qlocale_tools_p.h
+++ b/src/corelib/text/qlocale_tools_p.h
@@ -89,6 +89,23 @@ inline int wholePartSpace(double d)
return d > (1 << 19) ? std::numeric_limits<double>::max_exponent10 + 1 : 6;
}
+// Returns code-point of same kind (UCS2 or UCS4) as zero; digit is 0 through 9
+template <typename UcsInt>
+inline UcsInt unicodeForDigit(uint digit, UcsInt zero)
+{
+ // Must match QLocaleData::numericToCLocale()'s digit-digestion.
+ Q_ASSERT(digit < 10);
+ if (!digit)
+ return zero;
+
+ // See QTBUG-85409: Suzhou's digits are U+3007, U+2021, ..., U+3029
+ if (zero == 0x3007u)
+ return 0x3020u + digit;
+ // At CLDR 36.1, no other number system's digits were discontinuous.
+
+ return zero + digit;
+}
+
Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
Q_CORE_EXPORT double qstrntod(const char *s00, int len, char const **se, bool *ok);
qlonglong qstrtoll(const char *nptr, const char **endptr, int base, bool *ok);