summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale_win.cpp
Commit message (Collapse)AuthorAgeFilesLines
* String-view-ify qt_splitLocaleName() and simplify its callersEdward Welbourne2020-11-171-8/+6
| | | | | | | | | | | 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>
* MinGW: Fix compile error in qlocale_win.cppFriedemann Kleint2020-11-101-3/+3
| | | | | | | | | | | | | Cast enumerations to ushort, fixing: src/corelib/text/qlocale_win.cpp: In member function 'virtual QVariant QSystemLocale::query(QSystemLocale::QueryType, QVariant) const': src/corelib/text/qlocale_win.cpp:765:34: error: enumeral and non-enumeral type in conditional expression [-Werror=extra] As a drive-by, fix deprecation warning about QVariant::type(). Amends 098f43fdd2d46e15c87073aae44c5f2bd0cd8c98. Change-Id: I2adc9833c6d6d9e9d2500f0b92b25cb5d38b583b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QLocale: use uint lessEdward Welbourne2020-11-081-2/+2
| | | | | | | | | | Various uses of uint were simply redundant, now that Language, Script and Country are ushort-based. Others should in any case have been quint16 or char32_t. Change-Id: Id0d0dc2558e1724907907cde56059f70972e824a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use QLocaleId in place of language, script, country triplesEdward Welbourne2020-11-081-8/+4
| | | | | | | | | | | | 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>
* Deprecate QVariant::TypeLars Knoll2020-10-231-5/+5
| | | | | | | | | It's been obsolete for a long time already. Make sure the compiler now warns about it and remove all remaining uses in qtbase. Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix handling of Suzhou numbering systemEdward Welbourne2020-07-171-7/+9
| | | | | | | | | | | | | | | | 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>
* QSystemLocalePrivate::substituteDigits(): change to move semanticsEdward Welbourne2020-07-151-6/+6
| | | | | | | | | | Rather than passing an in-out reference parameter and ignoring the return (of that parameter) use an actual rvalue ref parameter and move the value through the function, to make it easier for compilers to see how to optimize it. Change-Id: Ie239400345da012d8fb8a731394f1687b8b62430 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify qlocale_win's getLocaleInfo() and its _int variantEdward Welbourne2020-07-151-32/+28
| | | | | | | | | | | | One of the former's overloads was a template; it and its _int variant took an optional maxlen; no caller passed maxlen, only three callers didn't over-ride the template's <QString> default return value to <QVariant>; so eliminate maxlen and have it simply return QVariant, using .toString() on it where needed. Change-Id: Icf3ff32f167ee96cfbb6412613ecd7f0886a2fe9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify qlocale_win's currency formattingEdward Welbourne2020-07-141-11/+5
| | | | | | | | | | | | Use QLocaleData::c()'s instance method, rather than QLocaleData's static method, to format integers. This avoids the need to duplicate various arguments as literals, that the C locale provides as default. It also future-proofs against changes to the static methods. Change-Id: I5bba407cfc29e3f33d1e9fa878ddf35fff3b113c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Remove winrtOliver Wolff2020-06-061-121/+0
| | | | | | | | | Macros and the await helper function from qfunctions_winrt(_p).h are needed in other Qt modules which use UWP APIs on desktop windows. Task-number: QTBUG-84434 Change-Id: Ice09c11436ad151c17bdccd2c7defadd08c13925 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Rework country setting to match how we return the script settingEdward Welbourne2020-04-211-3/+1
| | | | | Change-Id: I753673ef79b4ad208fa6e0c6a4eb8139cd2ee253 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Revert "Revert "QLocale: Actually get the language script for the system ↵Edward Welbourne2020-04-211-2/+3
| | | | | | | | | | | | | | | locale"" This reverts commit 449390c3a5f3a91e3895cbba0a583386e93366b7. QLocale::system() should behave consistently. If UI widgets are consulting the system locale where they should be consulting their configured UI locale, that is a bug in the UI widget and should not be "fixed" by breaking QLocale. Change-Id: Ib31cf7882a28b26f9a018fba3adabba94a8c43bf Pick-to: 5.15 Fixes: QTBUG-49031 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* Allow surrogate pairs for various "single character" locale dataEdward Welbourne2020-02-171-11/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fall back to "+" if MS returns empty string for positive signEdward Welbourne2020-02-031-1/+11
| | | | | | | | | | | MS's documentation says empty means "+" here, so implement that fallback (which shall over-ride whatever the CLDR has given us for the fallbackUiLanguage's positive sign). Task-number: QTBUG-81530 Change-Id: Ic3f10dd061d0c46d1433f29b8065988da94c38e6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qlocale_win.cpp: distinguish empty QString from null QVariantEdward Welbourne2020-02-031-26/+29
| | | | | | | | | | | | | | | | | An empty string, when packaged as a QVariant, is non-null (as a QVariant); and QSystemLocale::query()'s callers care about the difference. Some callers of the internal getLocaleInfo(LCTYPE type, int maxlen) need an actual QString return, while others are what query() returns, so need to return a QVariant; where the former want an empty string, the latter need a null QVariant. So make that getLocaleInfo() into a template, so callers can chose QString or QVariant as return type, only affecting the failure returns. Change-Id: I7b9a698badedc0e0d8aef8c6e85c22931c33297a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix flawed logic in QSystemLocalePrivate::getLocaleInfo()Edward Welbourne2020-01-301-3/+3
| | | | | | | | | | | If the first call to GetLocaleInfo() returned non-zero, then GetLastError()'s return has nothing to do with GetLocaleInfo(), since it didn't fail. The check for ERROR_INSUFFICIENT_BUFFER as last error needs to happen in the branch where GetLocaleInfo() failed, returning zero. Change-Id: Idb6eaad1515a003133c787998aff0c265ef98251 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix MS-Win system locale code to return QString for numeric tokensEdward Welbourne2020-01-161-35/+62
| | | | | | | | | | | | | | | | | QSystemLocale::query() is specified to return a QString (wrapped in a QVariant) for the various tokens used in formatting numbers (zero digit, signs, separators) but the MS-Win back-end was returning QChar (wrapped as QVariant) instead, using the first UCS-2 code-point of the string (even if this was the first of a surrogate pair). The same error shall be perpetrated by its caller, but we can at least DTRT in the back-end, ready for the coming fix (in Qt 6) to its caller. In the process, eliminate some local variables that shadowed a member variable and adapt number-conversion to cope with surrogate-pair digits. Optimised the latter for the case where zero is "0". Change-Id: Idfb416c301add4c961dde613b3dc28b2e31fd0af Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Pass QDate, QTime as value classes, rather than by const referenceEdward Welbourne2019-08-301-4/+4
| | | | | | | | | This can, of course, only be done in private APIs - but comment on public APIs to do the same at Qt 6. Change-Id: I3c79951572be3c37b0b0c5b1b05bced051a40964 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Move text-related code out of corelib/tools/ to corelib/text/Edward Welbourne2019-07-101-0/+1143
This includes byte array, string, char, unicode, locale, collation and regular expressions. Change-Id: I8b125fa52c8c513eb57a0f1298b91910e5a0d786 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>