summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale_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_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_p.h')
-rw-r--r--src/corelib/text/qlocale_p.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h
index 818fdf27a1..d822f86b72 100644
--- a/src/corelib/text/qlocale_p.h
+++ b/src/corelib/text/qlocale_p.h
@@ -463,14 +463,22 @@ inline char QLocaleData::numericToCLocale(QStringView in) const
if ((group == u"\xa0" || group == u"\x202f") && in == u" ")
return ',';
- const uint zeroUcs4 = zeroUcs();
- const uint tenUcs4 = zeroUcs4 + 10;
const uint inUcs4 = in.size() == 2
? QChar::surrogateToUcs4(in.at(0), in.at(1)) : in.at(0).unicode();
-
- if (zeroUcs4 <= inUcs4 && inUcs4 < tenUcs4)
- return '0' + inUcs4 - zeroUcs4;
-
+ const uint zeroUcs4 = zeroUcs();
+ // Must match qlocale_tools.h's unicodeForDigit()
+ if (zeroUcs4 == 0x3007u) {
+ // 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 ('0' <= inUcs4 && inUcs4 <= '9')
return inUcs4;