From cf82b73a0a5badb4ba3804a807c0e766e5ecd66c Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Thu, 24 Jun 2004 19:51:39 +0000 Subject: [PATCH] fixed keypresses handling to correctly translate Unicode characters to current locale's charset in GTK2+ANSI build git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28009 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 14 +++++++++----- src/gtk1/window.cpp | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 99366276c4..e471db7e9f 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1274,11 +1274,15 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context, if (event.m_uniChar < 256) event.m_keyCode = event.m_uniChar; #else - gunichar uniChar = g_utf8_get_char( str ); - // We cannot handle Unicode in non-Unicode mode - if (uniChar > 255) return; - - event.m_keyCode = uniChar; + wchar_t unistr[2]; + unistr[0] = g_utf8_get_char(str); + unistr[1] = 0; + wxCharBuffer ansistr(wxConvLocal.cWC2MB(unistr)); + // We cannot handle characters that cannot be represented in + // current locale's charset in non-Unicode mode: + if (ansistr.data() == NULL) return; + + event.m_keyCode = ansistr[0u]; #endif diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 99366276c4..e471db7e9f 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1274,11 +1274,15 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context, if (event.m_uniChar < 256) event.m_keyCode = event.m_uniChar; #else - gunichar uniChar = g_utf8_get_char( str ); - // We cannot handle Unicode in non-Unicode mode - if (uniChar > 255) return; - - event.m_keyCode = uniChar; + wchar_t unistr[2]; + unistr[0] = g_utf8_get_char(str); + unistr[1] = 0; + wxCharBuffer ansistr(wxConvLocal.cWC2MB(unistr)); + // We cannot handle characters that cannot be represented in + // current locale's charset in non-Unicode mode: + if (ansistr.data() == NULL) return; + + event.m_keyCode = ansistr[0u]; #endif -- 2.45.2