summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-01-23 10:53:01 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2020-02-03 15:33:53 +0100
commit3730452bfe098f8cdc68ec2183dd283a17f7ad39 (patch)
tree21b31438ada66dd10ae63b82b22b01f7a80e362c /src/corelib
parente0f9b57462226b4f5842d1e857612d6c8fbe38fd (diff)
Fall back to "+" if MS returns empty string for positive sign
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>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/text/qlocale_win.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp
index faaa15cf6b..4a38adf309 100644
--- a/src/corelib/text/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
@@ -216,9 +216,17 @@ inline int QSystemLocalePrivate::getLocaleInfo(LCTYPE type, LPWSTR data, int siz
template<typename T>
T QSystemLocalePrivate::getLocaleInfo(LCTYPE type, int maxlen)
{
+ // https://docs.microsoft.com/en-us/windows/win32/intl/locale-spositivesign
+ // says empty for LOCALE_SPOSITIVESIGN means "+", although GetLocaleInfo()
+ // is documented to return 0 only on failure, so it's not clear how it
+ // returns empty to mean this; hence the two checks for it below.
+ const QString plus = QStringLiteral("+");
QVarLengthArray<wchar_t, 64> buf(maxlen ? maxlen : 64);
if (!getLocaleInfo(type, buf.data(), buf.size())) {
- if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+ const auto lastError = GetLastError();
+ if (type == LOCALE_SPOSITIVESIGN && lastError == ERROR_SUCCESS)
+ return plus;
+ if (lastError != ERROR_INSUFFICIENT_BUFFER)
return {};
int cnt = getLocaleInfo(type, 0, 0);
if (cnt == 0)
@@ -227,6 +235,8 @@ T QSystemLocalePrivate::getLocaleInfo(LCTYPE type, int maxlen)
if (!getLocaleInfo(type, buf.data(), buf.size()))
return {};
}
+ if (type == LOCALE_SPOSITIVESIGN && !buf[0])
+ return plus;
return QString::fromWCharArray(buf.data());
}