]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed keypresses handling to correctly translate Unicode characters to current locale...
authorVáclav Slavík <vslavik@fastmail.fm>
Thu, 24 Jun 2004 19:51:39 +0000 (19:51 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Thu, 24 Jun 2004 19:51:39 +0000 (19:51 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28009 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/window.cpp
src/gtk1/window.cpp

index 99366276c4a4b9cd852c550bb470f5278ec457ab..e471db7e9fbaa9c76ca3dd9970c1ca239d3a0e43 100644 (file)
@@ -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
 
 
index 99366276c4a4b9cd852c550bb470f5278ec457ab..e471db7e9fbaa9c76ca3dd9970c1ca239d3a0e43 100644 (file)
@@ -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