Add .UTF-8 suffixes to locale-names passed to setlocale()

We use UTF-8 locales by default since Qt 6; and relatively few systems
have the encoding-unspecified locales we were trying to use, with the
result that the setlocale() calls all failed.

Task-number: COIN-689
Change-Id: Id791ba269bf4abac29da3daa4fd01684ca9caa7a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Edward Welbourne 2021-03-16 16:02:56 +01:00
parent 81fbcc4dc6
commit 421c69fde5
2 changed files with 4 additions and 3 deletions

View File

@ -922,7 +922,7 @@ void tst_QLocale::stringToDouble()
{
// Make sure result is independent of locale:
TransientLocale ignoreme(LC_ALL, "ar_SA");
TransientLocale ignoreme(LC_ALL, "ar_SA.UTF-8");
QCOMPARE(locale.toDouble(num_str, &ok), d);
QCOMPARE(ok, good);
}
@ -1009,7 +1009,7 @@ void tst_QLocale::stringToFloat()
{
// Make sure result is independent of locale:
TransientLocale ignoreme(LC_ALL, "ar_SA");
TransientLocale ignoreme(LC_ALL, "ar_SA.UTF-8");
QCOMPARE(locale.toFloat(num_str, &ok), f);
QCOMPARE(ok, good);
}
@ -1180,7 +1180,7 @@ void tst_QLocale::doubleToString()
const QLocale locale(localeName);
QCOMPARE(locale.toString(num, mode, precision), numStr);
TransientLocale ignoreme(LC_ALL, "de_DE");
TransientLocale ignoreme(LC_ALL, "de_DE.UTF-8");
QCOMPARE(locale.toString(num, mode, precision), numStr);
}

View File

@ -5630,6 +5630,7 @@ void tst_QString::localeAwareCompare()
QFETCH(QString, s1);
QFETCH(QString, s2);
QFETCH(int, result);
locale += QStringLiteral(".UTF-8"); // So we don't have to repeat it on every data row !
if (!locale.isEmpty()) {
#if defined (Q_OS_DARWIN) || QT_CONFIG(icu)