From 7a6016aec4fdb446bd4f515fe7c08e1496cd2a7c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 20 Dec 2022 10:07:00 +0100 Subject: [PATCH] QWindowsKeyMapper: make the code locale-independent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The C toupper function is locale-dependent. Given the right locale (Türkiye, e.g.), toupper(i) is either - İ (LATIN CAPITAL LETTER I WITH DOT ABOVE; if representable) or - i (unchanged; if it isn't) The latter is clearly wrong. The former might be what is wanted, but since most locales these days are UTF-8, Í will be unlikely to be representable in char. So I conclude that what's intended here is that i gets mapped to I, even in the Türkiye locale, so use the new QMiscUtils::toAsciiUpper() instead of toupper(). Fixes: QTBUG-109520 Pick-to: 6.5 6.4 Change-Id: I6fee2fb15c2facae79f1727455180567698fed80 Reviewed-by: Samuel Ghinet Reviewed-by: Thiago Macieira Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 044de5f3ea..3089e745d4 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #if defined(WM_APPCOMMAND) # ifndef FAPPCOMMAND_MOUSE @@ -599,8 +600,7 @@ static inline quint32 toKeyOrUnicode(quint32 vk, quint32 scancode, unsigned char static inline int asciiToKeycode(char a, int state) { - if (a >= 'a' && a <= 'z') - a = toupper(a); + a = QtMiscUtils::toAsciiUpper(a); if ((state & Qt::ControlModifier) != 0) { if (a >= 0 && a <= 31) // Ctrl+@..Ctrl+A..CTRL+Z..Ctrl+_ a += '@'; // to @..A..Z.._