[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using utf-8 with xterm
Tomas Frydrych writes:
> Now, how do I make my
> keyboard under XFree86 4 emit utf-8 codes? I use English locale,
> which I want to keep, but say would like to assign the Hebrew
> Aleph (UCS=0x5d0, utf-8 0xd7 0x90) to a particular key on the
> keyboard. I have tried to assign both 0x5d0 and 0xd790 to the key
> using xmodmap, but this does not work, the key will not generate
> anything at all (or so it seems).
This only works in an UTF-8 locale, not in other locales.
Note that UTF-8 locales are supported with glibc-2.2; with earlier
glibcs you need the LD_PRELOAD hacks described in the HOWTO.
This is actually an X11 limitation which has only recently been
lifted. With XFree86 4.0.2 and the appended xterm patch your keyboard
assignments should also work in non-UTF-8 locales.
Bruno
*** xc/programs/xterm/input.c.old Sun Nov 19 01:33:45 2000
--- xc/programs/xterm/input.c Wed Dec 6 11:53:09 2000
***************
*** 334,342 ****
int dec_code;
short modify_parm = 0;
int keypad_mode = ((keyboard->flags & MODE_DECKPAM) != 0);
- #if OPT_WIDE_CHARS
- long ucs;
- #endif
/* Ignore characters typed at the keyboard */
if (keyboard->flags & MODE_KAM)
--- 334,339 ----
***************
*** 351,398 ****
else
#endif
#if OPT_I18N_SUPPORT
! if (screen->xic
#if OPT_WIDE_CHARS
! && !screen->utf8_mode
#endif
! ) {
! Status status_return;
! nbytes = XmbLookupString (screen->xic, event,
! strbuf, sizeof(strbuf),
! &keysym, &status_return);
}
else
#endif
{
! static XComposeStatus compose_status = {NULL, 0};
! nbytes = XLookupString (event, strbuf, sizeof(strbuf),
! &keysym, &compose_status);
}
- #if OPT_WIDE_CHARS
- /*
- * FIXME: As long as Xlib does not provide proper UTF-8 conversion via
- * XLookupString(), we have to generate them here. Once Xlib is fully
- * UTF-8 capable, this code here should be removed again.
- */
- if (screen->utf8_mode) {
- ucs = -1;
- if (nbytes == 1) {
- /* Take ISO 8859-1 character delivered by XLookupString() */
- ucs = (unsigned char) strbuf[0];
- } else if (!nbytes &&
- ((keysym >= 0x100 && keysym <= 0xf000) ||
- (keysym & 0xff000000U) == 0x01000000))
- ucs = keysym2ucs(keysym);
- else
- ucs = -2;
- if (ucs == -1)
- nbytes = 0;
- if (ucs >= 0)
- nbytes = convertFromUTF8(ucs, (Char *)strbuf);
- }
- #endif
-
string = (Char *)&strbuf[0];
reply.a_pintro = 0;
reply.a_final = 0;
--- 348,398 ----
else
#endif
#if OPT_I18N_SUPPORT
! if (screen->xic) {
#if OPT_WIDE_CHARS
! if (screen->utf8_mode) {
! #if X_HAVE_UTF8_STRING /* XFree86 4.0.2 or newer */
! Status status_return;
! nbytes = Xutf8LookupString (screen->xic, event,
! strbuf, sizeof(strbuf),
! &keysym, &status_return);
! #else
! static XComposeStatus compose_status = {NULL, 0};
! long ucs = -1;
! nbytes = XLookupString (event, strbuf, sizeof(strbuf),
! &keysym, &compose_status);
! if (nbytes == 1) {
! /* An ISO 8859-1 character delivered by XLookupString() */
! ucs = (unsigned char) strbuf[0];
! } else if (!nbytes &&
! ((keysym >= 0x100 && keysym <= 0xf000) ||
! (keysym & 0xff000000U) == 0x01000000))
! ucs = keysym2ucs(keysym);
! else
! ucs = -2;
! if (ucs == -1)
! nbytes = 0;
! if (ucs >= 0)
! nbytes = convertFromUTF8(ucs, (Char *)strbuf);
#endif
! }
! else
! #endif
! {
! Status status_return;
! nbytes = XmbLookupString (screen->xic, event,
! strbuf, sizeof(strbuf),
! &keysym, &status_return);
! }
}
else
#endif
{
! static XComposeStatus compose_status = {NULL, 0};
! nbytes = XLookupString (event, strbuf, sizeof(strbuf),
! &keysym, &compose_status);
}
string = (Char *)&strbuf[0];
reply.a_pintro = 0;
reply.a_final = 0;
-
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/lists/