+ Status status;
+ gchar *buf, fixbuf[4]; /* 4 is enough for a utf8 char */
+ gint len, bufsz;
+ gboolean got_string = FALSE;
+
+ if (!ic)
+ g_warning("Using obt_keyboard_keypress_to_unichar() without an "
+ "Input Context. No i18n support!");
+
+ if (ic && ic->xic) {
+ buf = fixbuf;
+ bufsz = sizeof(fixbuf);
+
+#ifdef X_HAVE_UTF8_STRING
+ len = Xutf8LookupString(ic->xic, ev, buf, bufsz, &sym, &status);
+#else
+ len = XmbLookupString(ic->xic, ev, buf, bufsz, &sym, &status);
+#endif
+
+ if (status == XBufferOverflow) {
+ buf = g_new(char, len);
+ bufsz = len;
+
+#ifdef X_HAVE_UTF8_STRING
+ len = Xutf8LookupString(ic->xic, ev, buf, bufsz, &sym, &status);
+#else
+ len = XmbLookupString(ic->xic, ev, buf, bufsz, &sym, &status);
+#endif
+ }