Use case-insensitive comparison to compare codec with UTF-8 and utf8

Given that the two candidate "counts as UTF 8" values for codec differ
in case, it seems prudent to use a case-insensitive comparison, in
case we hit UTF8 or utf-8.

Pick-to: 6.5 6.4 6.2
Change-Id: I279f83eafa90dd2685c306144c99ec97177d1d3b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
bb10
Edward Welbourne 2023-01-17 16:21:24 +01:00
parent f4e212b9c4
commit 75ae8869fb
1 changed files with 1 additions and 1 deletions

View File

@ -601,7 +601,7 @@ void QCoreApplicationPrivate::initLocale()
const char *locale = setlocale(LC_ALL, "");
const char *codec = nl_langinfo(CODESET);
if (Q_UNLIKELY(strcmp(codec, "UTF-8") != 0 && strcmp(codec, "utf8") != 0)) {
if (Q_UNLIKELY(qstricmp(codec, "UTF-8") != 0 && qstricmp(codec, "utf8") != 0)) {
QByteArray oldLocale = locale;
QByteArray newLocale = setlocale(LC_CTYPE, nullptr);
if (qsizetype dot = newLocale.indexOf('.'); dot != -1)