From 2302fc9d358b13c7bf9992ac9a1376c20bdaee35 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 17 Jan 2023 16:21:24 +0100 Subject: [PATCH] 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. Change-Id: I279f83eafa90dd2685c306144c99ec97177d1d3b Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz (cherry picked from commit 75ae8869fb171493e4d5163910ef3a2034902c7d) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qcoreapplication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 0c4828b0f32..096c2b1d2e7 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -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)