summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-12-20 10:07:00 +0100
committerMarc Mutz <marc.mutz@qt.io>2023-01-03 15:57:37 +0000
commit7a6016aec4fdb446bd4f515fe7c08e1496cd2a7c (patch)
tree17c8980440aa7ddbdb284c68655af403030bdd78 /src/plugins/platforms
parent8bf602518d8440542329d867c1a710b66ae12c36 (diff)
QWindowsKeyMapper: make the code locale-independent
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 <ctype.h> toupper(). Fixes: QTBUG-109520 Pick-to: 6.5 6.4 Change-Id: I6fee2fb15c2facae79f1727455180567698fed80 Reviewed-by: Samuel Ghinet <samuel.ghinet@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp4
1 files 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 <QtGui/qevent.h>
#include <QtGui/private/qwindowsguieventdispatcher_p.h>
#include <QtCore/private/qdebug_p.h>
+#include <QtCore/private/qtools_p.h>
#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.._