summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Teach QLocale::system() to use narrow formatIvan Solovev2021-09-151-1/+5
| | | | | | | | | | | | | | | | QLocale::system() was not making use of QLocaleFormat::Narrow, always treating it in the same way as QLocaleFormat::Short. This patch fixes the issue for day and month names. The implementation falls back to CLDR if system locale fails to provide some data. Pick-to: 6.2 Task-number: QTBUG-84877 Change-Id: Ia37e59dbf02d7a5e230f2767d294b9ab7de37f33 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix QLocale::system() standalone day and month handlingIvan Solovev2021-09-061-1/+3
| | | | | | | | | | | | | | | Some backends were missing support for standalone days and months, also the standaloneDayName() implementation was always using the same codepath as dayName(). This patch fixes the issues. Support for narrow format will be added in the following patch. Task-number: QTBUG-84877 Pick-to: 6.2 Change-Id: I38ee06342cafab544e3c69097bd0e6ae68e85645 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add a QLocale(QStringView) constructorEdward Welbourne2021-09-011-1/+1
| | | | | | | | | | | Only a few more internals just needed to change to take QStringView, to connect up the constructor with internals already long since converted. [ChangeLog][QtCore][QLocale] Added QLocale(QStringView) constructor. Change-Id: Iec31391e6168f333b4b6fc633c3d7d01872f83b3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Mark QLocale's private functions [[nodiscard]]Edward Welbourne2021-09-011-80/+91
| | | | | | | | If only to make the exceptions stand out, so we can see which ones only exist for their side-effects. Change-Id: I90b649d4da09f57ab986f29c577993dd12e34721 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Rework QLocalePrivate::bytearrayToU?LongLong()Edward Welbourne2021-08-301-3/+3
| | | | | | | | | | | | Change it to take a QByteArrayView instead of a plain char *; all its callers do know the size and propagating it enables the implementation to call strntou?ll() rather than strtou?ll(), thereby escaping the need for '\0'-termination. Fixes: QTBUG-74286 Change-Id: Ie9394786e9fcf25c1d1be2421805f47c018d13bb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QString::localeAwareCompare: adapt to QLocale::setDefault() being calledThiago Macieira2021-08-021-0/+2
| | | | | | | | | | | | | | | | | Because we're using a thread-specific global static, we need to recreate the QCollator type every time setDefault() is called. Since one is stored per-thread, we simply increment a generational counter and check that the next time that QString::localeAwareCompare is called in each thread. The issue was introduced on f6425da424b1a0d5927ee56fa657a9b31ca5afd1 (5.12) even though we were supposed to be using QCollator since commit 5279134935e858e6fa8565c936b17e88d7bded50 (5.3). Fixes: QTBUG-95050 Pick-to: 6.2 Change-Id: I7e0b82c2d2fe464082d8fffd1696a8c9f74e5b30 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix augmentation of UI language listEdward Welbourne2021-06-071-1/+0
| | | | | | | | | | | | | | | | | | | | Previously, the augmentation wasn't being applied to the system locale, due to a mistaken test claiming the locale's name didn't resemble the string from which it was constructed. The test dates from before various fixes to likely sub-tag processing that should make it redundant now. This makes QLocalePrivate::rawName() also redundant (and its conversion of QLatin1String to QByteArray relied on '\0' termination which wasn't actually present in the various codes). Expanded the test of systemLocale() to also test uiLanguages() turns a single entry into the list we expect; and add two new test-cases. (The test uses a mock system locale class, making this independent of the platform backend.) Fixes: QTBUG-92234 Pick-to: 6.1 5.15 Change-Id: I0cdf6eae152a42dc377f4ea3e62c282ff4be1764 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add the "Territory" enumerated type for QLocaleJiDe Zhang2021-04-151-15/+15
| | | | | | | | | | | | | | | | | | | The use of "Country" is misleading as some entries in the enumeration are not countries (eg, HongKong), for all that most are. The Unicode Consortium's Common Locale Data Repository (CLDR, from which QLocale's data is taken) calls these territories, so introduce territory-based names and prepare to deprecate the country-based ones in due course. [ChangeLog][QtCore][QLocale] QLocale now has Territory as an alias for its Country enumeration, and associated territory-based names to match its country-named methods, to better match the usage in relevant standards. The country-based names shall in due course be deprecated in favor of the territory-based names. Fixes: QTBUG-91686 Change-Id: Ia1ae1ad7323867016186fb775c9600cd5113aa42 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clarify what QSystemLocale::fallbackLocale() is used forTor Arne Vestbø2021-02-091-3/+3
| | | | | Change-Id: I8f073f996505ccb42020b32fd76520ecef54e628 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocale: Allow direct conversion from language, country, and script codesKai Köhne2021-01-251-1/+0
| | | | | | | | | | | | | | | This complements patch a148c7b5d71d244, where languageToCode(), countryToCode() scriptToCode() methods were introduced, with matching codeToLanguage(), codeToCountry(), and codeToScript() methods. This allows us to remove the use of private Qt Core API in Qt Linguist. [ChangeLog][QtCore][QLocale] Added static codeToLanguage(), codeToCountry(), codeToScript() methods that convert ISO code strings to the respective enum values. Change-Id: If5c0843a718c006ade086a6f74ceb86ac6e0fce4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocale: Remove dead codeKai Köhne2021-01-061-2/+0
| | | | | | | The code using it got removed in qttools commit 01da5d9a Change-Id: I14d36ac939f2647139fcc42591a044a03e707553 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-1/+1
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Get rid of Q_COMPILER_CONSTEXPR checksAllan Sandfeld Jensen2020-11-171-2/+0
| | | | | | | Is required now. Change-Id: I62e95929d1649ea1390392230b619bd56d2a0349 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* String-view-ify qt_splitLocaleName() and simplify its callersEdward Welbourne2020-11-171-1/+2
| | | | | | | | | | | Two of its callers didn't even care about the fragments it was returning, one only cared about two of them. The parsing could be more straightforward and less verbose. Parsing into QStringView saves the need to allocate copies of the substrings parsed. Cleaned up around the code that called it. Change-Id: Ie65d2b1b3eb891c20bc82275d7a0da00c30d7b8d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Export QLocaleId::fromName() so qttools can use itEdward Welbourne2020-11-171-1/+2
| | | | | | | | This shall replace QLocalePrivate::getLangAndCountry()'s use by qttools. Change-Id: Ib686a3769bd38c477d7fbad50cf494ee8a0b1c00 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Replace QLocalePriave::create() with a plain constructorEdward Welbourne2020-11-081-18/+10
| | | | | | | | | | Be up front about using new in all the places where it's created. Made one of the global statics into a function-local static. Eliminated a static made redundant by its const sibling. Made two members const now that they can be. Change-Id: I46532b3c1e0e62d1f8c84f55494f70cff09d4404 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace fallbackUiLocaleData() with fallbackUiLocaleIndex()Edward Welbourne2020-11-081-2/+2
| | | | | | | | | | | | | This means always initializing globalLocaleData from an entry in the locale_data array, where in principle the fallbackUiLocale() could be the system locale, which isn't held in the array. However, no actual implementation of fallbackUiLocale() uses the system locale (nor is it clear this would work if one did). Change-Id: Ie1c5ef3e8a97f21e0d82fa2dfb3cf3eb9e4c8840 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Rename QLocalePrivate's m_data_offset to m_indexEdward Welbourne2020-11-081-4/+5
| | | | | | | Change-Id: I1d27e6e57893c2f96df40746e1280fc8428e9ec1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Always pass index when creating a QLocalePrivateEdward Welbourne2020-11-081-1/+1
| | | | | | | | | | | | | | Previously, two calls using the default locale (which has an index in the locale_data array when it isn't the system locale) neglected to pass the index and the call for the system locale had no idnex, where it should really set the index appropriate to its language, script and country, so that we get appropriate calendar data to go with the system locale. One other place that handled the default locale also neglected to revise the index it was using. Change-Id: I4cc52e2d085a99e61236c91c0ae873b3bde5f11d Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use QLocaleId in place of language, script, country triplesEdward Welbourne2020-11-081-3/+2
| | | | | | | | | | | | Pass a single argument in place of three; and (prepare to) replace QLocalePrivate::getLangAndCountry(), taking three out parameters, with QLocaleId::fromName(). Removal of getLangAndCountry() must wait for removal of linguist's use of it in qttools, which has to wait for this change to land in qtbase. In the process, change findLocaleIndex()'s return to int. Change-Id: I9f5c44c41f2dd1598c53ed5ccb0abddc6b17d21f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Rework finding of locale data to be index-basedEdward Welbourne2020-11-081-8/+5
| | | | | | | | | | | | | | | | Instead of returning a pointer (from which we then have to infer an index for use in calendar data access), compute the index as primary and infer the data pointer from it. Also refer to the index as such, rather than as an offset. Comments advocating this wanted to dispense with the pointer entirely; that's not an option, however, due to the system locale having its data in a separate object, outside the array that contains all the other locales' data. Change-Id: I1c60e688229394003e61372dbfc6cfb11086eafa Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add some inline methods to make code more readableEdward Welbourne2020-11-081-0/+24
| | | | | | | | | | | | | | | | | Give QLocaleId matchesAny() and isValid() checks and some acceptance tests for their use as filters. Give QLocaleData a QLocaleId id(). A few messy pieces of code get easier to read. In the process, greatly simplify a do-while loop (sacrificing some pretest-before-loop optimizations - benchmarking shows they made negligible difference) and change a while loop to match its form, since it was doing essentially the same iteration and (thus) its condition was guaranteed true on the first iteration. Change-Id: I36b1a6ca8a3cf350b3f3abbe75b177e5a7637cd8 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Eliminate QLocaleId::fromIds() in favor of {...} constructionEdward Welbourne2020-10-121-8/+1
| | | | | | | | It's a value type, we don't need a pseudo-constructor to bypass constructors. Change-Id: Ic4774c82e43ab7e2c54ac743026ce087e34c150f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use char32_t for QLocaleData::zeroUcs() and friendsEdward Welbourne2020-08-281-12/+9
| | | | | | | | | | Also catch some stray ushort that should be char16_t by now, use unicode character values for some constants and rename a UCS2 variable to not claim it's UCS4. Change-Id: I374b791947f5c965eaa22ad5b16060b475081c9d Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-1/+1
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QLocaleData: remove unused internal functionThiago Macieira2020-07-281-1/+0
| | | | | | Pick-to: 5.15 Change-Id: Iea47e0f8fc8b40378df7fffd1624bf3469e66c90 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix handling of Suzhou numbering systemEdward Welbourne2020-07-171-6/+14
| | | | | | | | | | | | | | | | 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>
* Simplify uses of QSystemLocale::query()Edward Welbourne2020-07-151-1/+1
| | | | | | | | | | | | | | | QVariant::isNull() shall no longer return true when the variant does package an object, but that object's isNull() is true, so take care to catch QString-wrapping returns that contain an empty string, except where this is a valid return. Generally tidy code processing the returned value. At the same time, make the second argument of query() optional, since it's only used by a subset of the query types. Change-Id: I3dba9a59260f9f182ca277784c77277e2ea255e2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Support digit-grouping correctlyEdward Welbourne2020-07-141-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Refactor QLocale's integer formattingEdward Welbourne2020-07-141-0/+2
| | | | | | | | | Break out some shared code in the integer formatting to save duplicating it. Simplify what's left. Renamed some variables to match Qt style. Change-Id: I369a013802a267a94725302de0d1d33291c29538 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocalePrivate: rearrange number format statics and toolsEdward Welbourne2020-07-141-13/+15
| | | | | | | | | | | | Instead of passing lots of instance data around among public static methods and functions in qlocale_tools, do the work in instance methods that can access the relevant attributes of the locale when they need them. Incidentally reduces clutter in the global namespace. Add a signPrefix() to handle a repeated computation. Keep new internal methods private. Change-Id: I9556a960acac9fb645872337c61f509fb902984e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use numeric_limits instead of hand-coded equivalentsEdward Welbourne2020-07-131-11/+0
| | | | | | | | | | | | | | As a comment noted, the reason for QLocaleData rolling its own values describing the ranges of digits and exponents in a double were all about std::numeric_limits's constants not being constexpr - which they have now been since C++11, so we can do away with our own. One of the constants was used in two places in the same way; so abstract that use out into an inline function in qlocale_tools, to save duplication and give somewhere to document it. Change-Id: I7e3740ece9b499c0ec434de18d70abe69e1fe079 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-191-13/+13
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port QLocale::quoteString from QStringRef to QStringViewLars Knoll2020-06-111-3/+3
| | | | | | | Task-number: QTBUG-84319 Change-Id: I29726ebfda7a5f51a0a6ee29e905b0b904256c8d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use char16_t in favor of ushort for locale data tablesEdward Welbourne2020-02-171-7/+7
| | | | | | Change-Id: I890dd2b52c1b786db1081744c8ca343baba93de4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Allow surrogate pairs for various "single character" locale dataEdward Welbourne2020-02-171-43/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extract the character in its proper unicode form and encode it in a new single_character_data table of locale data. Record each entry as the range within that table that encodes it. Also added an assertion in the generator script to check that the digits CLDR gives us are a contiguous sequence in increasing order, as has been assumed by the C++ code for some time. Lots of number-formatting code now has to take account of how wide the digits are. This leaves nowhere for updateSystemPrivate() to record values read from sys_locale->query(), so we must always consult that function when accessing these members of the systemData() object. Various internal users of these single-character fields need the system-or-CLDR value rather than the raw CLDR value, so move QLocalePrivate's methods to supply them down to QLocaleData and ensure they check for system values, where appropriate first. This allows us to finally support the Chakma language and script, for whose number system UTF-16 needs surrogate pairs. Costs 10.8 kB in added data, much of it due to adding two new locales that need surrogates to represent digits. [ChangeLog][QtCore][QLocale] Various QLocale methods that returned single QChar values now return QString values to accommodate those locales which need a surrogate pair to represent the (single character) return value. Fixes: QTBUG-69324 Fixes: QTBUG-81053 Change-Id: I481722d6f5ee266164f09031679a851dfa6e7839 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.15' into devLiang Qi2020-02-131-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/widgets/graphicsview/boxes/scene.h src/corelib/Qt5CoreMacros.cmake src/corelib/Qt6CoreMacros.cmake src/network/ssl/qsslsocket.cpp src/network/ssl/qsslsocket.h src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp src/testlib/CMakeLists.txt src/testlib/.prev_CMakeLists.txt tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp Disabled building manual tests with CMake for now, because qmake doesn't do it, and it confuses people. Done-With: Alexandru Croitor <alexandru.croitor@qt.io> Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Change-Id: I865ae347bd01f4e59f16d007b66d175a52f1f152
| * Enable system locale to skip digit-grouping if configured to do soEdward Welbourne2020-02-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On macOS it's possible to configure the system locale to not do digit grouping (separating "thousands", in most western locales); it then returns an empty string when asked for the grouping character, which QLocale's system-configuration then ignored, falling back on using the base UI locale's grouping separator. This could lead to the same separator being used for decimal and grouping, which should never happen, least of all when configured to not group at all. In order to notice when this happens, query() must take care to return an empty QString (as a QVariant, which is then non-null) when it *has* a value for the locale property, and that value is empty, as opposed to a null QVariant when it doesn't find a configured value. The caller can then distinguish the two cases. Furthermore, the group and decimal separators need to be distinct, so we need to take care to avoid cases where the system overrides one with what the CLDR has given for the other and doesn't over-ride that other. Only presently implemented for macOS and MS-Win, since the (other) Unix implementation of the system locale returns single QChar values for the numeric tokens - see QTBUG-69324, QTBUG-81053. Fixes: QTBUG-80459 Change-Id: Ic3fbb0fb86e974604a60781378b09abc13bab15d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Separate offsets from sizes in QLocale's dataEdward Welbourne2020-01-301-54/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This enables us to make the sizes quint8 and benefit from the resulting packing, making the locale data smaller. The sizes for long month-name lists (which concatenate twelve names with semicolon as separator) can overflow an 8-bit member, so use quint16 where needed. Re-ordered the data in QLocaleData and QCalendarLocale. Now all long-short(-narrow) families arise in that order; and any standalone is grouped with the one of the same length. (This cost 20 bytes in the date-format table, which optimises out more duplication if short is before long, but the saving in the (smaller) time-format table more than make up for it; and 20 bytes isn't worth the confusion that being inconsistent in ordering might cause.) At the same time, drop trailing semicolons from list entries (which join various names with semicolon) as they're not needed: we know where the end of the list is, because we know the size of the string that results from concatenation. The code that parses such lists can even correctly handle empty entries at the end. Saves 26 kB of data in the compiled binaries. Task-number: QTBUG-81053 Change-Id: If6ccc96a6910828817aa605d10fd814f567ae1e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Refactor QLocale's data access to be less verboseEdward Welbourne2020-01-301-1/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | Add QLocaleData::DataRange and methods returning it, to package each of the m_*_idx, m_*_size pairs of data members, to simplify access to these data. This extends the experiment started in QCalendarLocale, which is now adapted to use the new DataRange also. Two static functions of qlocale.cpp are replaced by methods of DataRange, saving considerable duplication of long member names in callers. Change-Id: Iad9899ba72f00522594b55a0402baec47491999c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Preserve the case of the exponent separator CLDR suppliesEdward Welbourne2020-01-301-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | We have long (since 4.5.1) coerced it to lower-case, for no readily apparent, much less documented, reason. CLDR says most locales use an upper-case E for this - let's actually use what CLDR says we should use. The code that matches the exponent separator was doing so case-insensitively in any case; that needed adaptation now that the separator's case isn't pre-determined; and, in any case, should have been done using case-folding rather than upper-casing. In the process, removed some spurious checks for "'e' or 'E'" in the result, since the exponent separator is always represented by 'e' (and an 'e' might also be present for the separate reason of its use as a beyond-decimal digit representing fourteen). [ChangeLog][QtCore][QLocale] QLocale::exponential() now preserves the case of the CLDR source, where previously it was lower-cased. Change-Id: Ic9ac02136cff79cb9f136d72141b5dbf54d9e0a6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QLocale: Support Indian number formattingTuomas Heimonen2019-12-301-1/+2
| | | | | | | | | | | When QLocale::Country is set to QLocale::India numbers are written so that after first three from the right and then after every second will be comma. E.g. 10000000 is written as 1,00,00,000 Task-number: QTBUG-24301 Change-Id: Ic06241c127b0af1824104f94f7e2ce6e2058a070 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Teemu Holappa <teemu.holappa@qt.io>
* Include likely-adjusted uiLanguages for the system localeEdward Welbourne2019-10-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QLocale::uiLanguages() on the system locale uses whatever the system locale's query(QSystemLocale::UILanguages,...) returns. On Android, this is just a list of locales. However, for non-system locales, we also include some results of removing likely sub-tags from the locale name, where equivalent. Thus zh-CN would also get zh and zh-Hans-CN added to it; however, if the system locale is zh-Hans-CN, the shorter forms are omitted. So post-process the system locale list in the same way, albeit tweaked to avoid duplicates and rearranged so that we can insert likely-adjusted entries between what they adjust and what followed it. Added QLocalePrivate::rawName() in the process, since it looks likely to be useful in other contexts (and I needed its value): it just joins such tags as are non-Any. This, however, uses QByteArrayList, so added that (it's small) to the bootstrap library and qmake. This follows up on commit 8796e3016fae1672e727e2fa4e48f671a0c667ba. [ChangeLog][QtCore][QLocale] The system locale's UI languages list now includes, as for that of an ordinary locale, the results of adding likely sub-tags from each locale name, and of removing some, where this doesn't change which locale is specified. This gives searches for translation files a better chance of finding a suitable file. Fixes: QTBUG-75413 Change-Id: Iaafd79aac6a0fdd5f44aed16e445e84a2267c9da Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add support for calendars beside GregorianSoroush Rabiei2019-08-201-16/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add QCalendarBackend as a base class for calendar implementations and QCalendar as a facade via which to access it. QDate's implicit implementation of the Gregorian calendar becomes QGregorianCalendar and QDate methods now support choice of calendar. Convert QLocale's CLDR data for month names to a locale-data component of each supported calendar and relevant QLocale methods now support choice of calendar. Adapt Python scripts for locale data generation to extract month name data from CLDR (keeping on version v35.1) into the new calendar-locale files. The locale data for the Gregorian calendar is held in a Roman calendar base, for sharing with other calendars. Add tests for basic uses of the new API. [ChangeLog][QtCore][QCalendar] Added QCalendar to support diverse calendars, supported by implementing QCalendarBackend. [ChangeLog][QtCore][QDate] Allow choice of calendar in various operations, with Gregorian remaining the default. Done-with: Lars Knoll <lars.knoll@qt.io> Done-with: Edward Welbourne <edward.welbourne@qt.io> Fixes: QTBUG-17110 Fixes: QTBUG-950 Change-Id: I9d6278f394269a183aee8156e990cec4d5198ab8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Move text-related code out of corelib/tools/ to corelib/text/Edward Welbourne2019-07-101-0/+471
This includes byte array, string, char, unicode, locale, collation and regular expressions. Change-Id: I8b125fa52c8c513eb57a0f1298b91910e5a0d786 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>