diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-01-17 11:00:24 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-07-14 14:52:08 +0200 |
commit | bb6a73260ec8272647265f42180963604ad0f755 (patch) | |
tree | a85d2f1f0a2e11eaa9ed8dcb2e7d3032faa4acf2 /src/corelib/serialization/qtextstream.cpp | |
parent | 19ed60d703f9071d183760a8ce1c50009c780bf8 (diff) |
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 <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qtextstream.cpp')
-rw-r--r-- | src/corelib/serialization/qtextstream.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp index 3f0c25fd17..fffdf2d82e 100644 --- a/src/corelib/serialization/qtextstream.cpp +++ b/src/corelib/serialization/qtextstream.cpp @@ -2269,7 +2269,7 @@ void QTextStreamPrivate::putNumber(qulonglong number, bool negative) // add thousands group separators. For backward compatibility we // don't add a group separator for C locale. if (locale != QLocale::c() && !locale.numberOptions().testFlag(QLocale::OmitGroupSeparator)) - flags |= QLocaleData::ThousandsGroup; + flags |= QLocaleData::GroupDigits; const QLocaleData *dd = locale.d->m_data; int base = params.integerBase ? params.integerBase : 10; @@ -2485,7 +2485,7 @@ QTextStream &QTextStream::operator<<(double f) flags |= QLocaleData::AddTrailingZeroes | QLocaleData::ShowBase; } if (locale() != QLocale::c() && !(numberOptions & QLocale::OmitGroupSeparator)) - flags |= QLocaleData::ThousandsGroup; + flags |= QLocaleData::GroupDigits; if (!(numberOptions & QLocale::OmitLeadingZeroInExponent)) flags |= QLocaleData::ZeroPadExponent; if (numberOptions & QLocale::IncludeTrailingZeroesAfterDot) |