diff --git a/intern/ghost/intern/GHOST_SystemX11.cc b/intern/ghost/intern/GHOST_SystemX11.cc index de81a9ddf8f..567fe3b228e 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cc +++ b/intern/ghost/intern/GHOST_SystemX11.cc @@ -1108,10 +1108,9 @@ void GHOST_SystemX11::processEvent(XEvent *xe) } if (ELEM(status, XLookupChars, XLookupBoth)) { - if (uchar(utf8_buf[0]) >= 32) { /* not an ascii control character */ - /* do nothing for now, this is valid utf8 */ - } - else { + /* Check for ASCII control characters. + * Inline `iscntrl` because the users locale must not change behavior. */ + if ((utf8_buf[0] < 32 && utf8_buf[0] > 0) || (utf8_buf[0] == 127)) { utf8_buf[0] = '\0'; } } diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 4c17e4590c4..4ecb715a260 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -5670,7 +5670,9 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, const int type, event.utf8_buf[0] = '\0'; } else { - if (event.utf8_buf[0] < 32 && event.utf8_buf[0] > 0) { + /* Check for ASCII control characters. + * Inline `iscntrl` because the users locale must not change behavior. */ + if ((event.utf8_buf[0] < 32 && event.utf8_buf[0] > 0) || (event.utf8_buf[0] == 127)) { event.utf8_buf[0] = '\0'; } }