From bb6a73260ec8272647265f42180963604ad0f755 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 17 Jan 2020 11:00:24 +0100 Subject: Support digit-grouping correctly Read three more values from CLDR and add a byte to the bit-fields at the end of QLocaleData, indicating the three group sizes. This adds three new parameters to various low-level formatting functions. At the same time, rename ThousandsGroup to GroupDigits, more faithfully expressing what this (internal) option means. This replaces commit 27d139128013c969a939779536485c1a80be977e with a fuller implementation that handles digit-grouping in any of the ways that CLDR supports. The formerly "Indian" formatting now also applies to at least some locales for Bangladesh, Bhutan and Sri Lanka. Fixed Costa Rica currency formatting test that wrongly put a separator after the first digit; the locale (in common with several Spanish locales) requires at least two digits before the first separator. [ChangeLog][QtCore][Important Behavior Changes] Some locales require more than one digit before the first grouping separator; others use group sizes other than three. The latter was partially supported (only for India) at 5.15 but is now systematically supported; the former is now also supported. Task-number: QTBUG-24301 Fixes: QTBUG-81050 Change-Id: I4ea4e331f3254d1f34801cddf51f3c65d3815573 Reviewed-by: Thiago Macieira --- tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/auto/corelib/text/qlocale/tst_qlocale.cpp') diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index 551d63c269..1d43e35959 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -2682,7 +2682,9 @@ void tst_QLocale::currency() const QLocale es_CR(QLocale::Spanish, QLocale::CostaRica); QCOMPARE(es_CR.toCurrencyString(double(1565.25)), - QString::fromUtf8("\xE2\x82\xA1" "1\xC2\xA0" "565,25")); + QString::fromUtf8("\xE2\x82\xA1" "1565,25")); + QCOMPARE(es_CR.toCurrencyString(double(12565.25)), + QString::fromUtf8("\xE2\x82\xA1" "12\xC2\xA0" "565,25")); const QLocale system = QLocale::system(); QVERIFY(system.toCurrencyString(1, QLatin1String("FOO")).contains(QLatin1String("FOO"))); @@ -3135,9 +3137,7 @@ void tst_QLocale::numberGroupingIndia() void tst_QLocale::numberFormatChakma() { - // Initially India's flavour, since the number formatting is currently only - // done right for India. Should change to Bangladesh once that's fixed. - const QLocale chakma(QLocale::Chakma, QLocale::ChakmaScript, QLocale::India); + const QLocale chakma(QLocale::Chakma, QLocale::ChakmaScript, QLocale::Bangladesh); const uint zeroVal = 0x11136; // Unicode's representation of Chakma zero const QChar data[] = { QChar::highSurrogate(zeroVal), QChar::lowSurrogate(zeroVal), -- cgit v1.2.3