Restore Android-conditioning on nl_langinfo() definition
QCoreApplicationPrivate::initLocale()'s check that the selected locale is UTF-8-based was added with an initial work-around for Android, specific to NDK <= 15, which Qt 5.15 did not support. Later the Android-specific #if-ery was changed to test for Qt taking UTF-8 for granted, for a given reason having to do with QNX; and later the #if-ery for that was removed. However, we still support versions of Android that lack nl_langinfo(), so restore the Android #if-ery. It presently seems that NDK 26 (Android 8) does contain nl_langinfo(), so we should be able to drop the nl_langinfo() kludge for this and later versions. That way we'll at least use the real nl_langinfo() where we have it. In the process, fix the indentation of #if-ery. Change-Id: Ie9e83c3397955c24cea1e9a9ff6bb0187e47dda2 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 10117f78d72498e19683e69b439ca7c931532261) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e3daea6f17
commit
65f8f50b10
@ -590,12 +590,14 @@ void QCoreApplicationPrivate::initLocale()
|
|||||||
return;
|
return;
|
||||||
qt_locale_initialized = true;
|
qt_locale_initialized = true;
|
||||||
|
|
||||||
#ifdef Q_OS_INTEGRITY
|
# ifdef Q_OS_INTEGRITY
|
||||||
setlocale(LC_CTYPE, "UTF-8");
|
setlocale(LC_CTYPE, "UTF-8");
|
||||||
#else
|
# else
|
||||||
// Android's Bionic didn't get nl_langinfo until NDK 15 (Android 8.0),
|
# if defined(Q_OS_QNX) || (defined(Q_OS_ANDROID) && __ANDROID_API__ < __ANDROID_API_O__)
|
||||||
// which is too new for Qt, so we just assume it's always UTF-8.
|
// Android 6 still lacks nl_langinfo(), as does QNX, so we just assume it's
|
||||||
|
// always UTF-8 on these platforms.
|
||||||
auto nl_langinfo = [](int) { return "UTF-8"; };
|
auto nl_langinfo = [](int) { return "UTF-8"; };
|
||||||
|
# endif // QNX or Android NDK < 26, "O".
|
||||||
|
|
||||||
const char *locale = setlocale(LC_ALL, "");
|
const char *locale = setlocale(LC_ALL, "");
|
||||||
const char *codec = nl_langinfo(CODESET);
|
const char *codec = nl_langinfo(CODESET);
|
||||||
@ -610,10 +612,10 @@ void QCoreApplicationPrivate::initLocale()
|
|||||||
newLocale = setlocale(LC_CTYPE, newLocale);
|
newLocale = setlocale(LC_CTYPE, newLocale);
|
||||||
|
|
||||||
// if locale doesn't exist, try some fallbacks
|
// if locale doesn't exist, try some fallbacks
|
||||||
# ifdef Q_OS_DARWIN
|
# ifdef Q_OS_DARWIN
|
||||||
if (newLocale.isEmpty())
|
if (newLocale.isEmpty())
|
||||||
newLocale = setlocale(LC_CTYPE, "UTF-8");
|
newLocale = setlocale(LC_CTYPE, "UTF-8");
|
||||||
# endif
|
# endif
|
||||||
if (newLocale.isEmpty())
|
if (newLocale.isEmpty())
|
||||||
newLocale = setlocale(LC_CTYPE, "C.UTF-8");
|
newLocale = setlocale(LC_CTYPE, "C.UTF-8");
|
||||||
if (newLocale.isEmpty())
|
if (newLocale.isEmpty())
|
||||||
@ -624,8 +626,8 @@ void QCoreApplicationPrivate::initLocale()
|
|||||||
"reconfigure your locale. See the locale(1) manual for more information.",
|
"reconfigure your locale. See the locale(1) manual for more information.",
|
||||||
codec, oldLocale.constData(), newLocale.constData());
|
codec, oldLocale.constData(), newLocale.constData());
|
||||||
}
|
}
|
||||||
#endif
|
# endif // Integrity
|
||||||
#endif
|
#endif // Unix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user