[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UTF-8 keyboard mode



Frank da Cruz wrote on 1999-09-17 14:18 UTC:
> A terminal emulator needs either raw keyboard events
> (make/break codes, up/down events, e.g. for PCTERM), or at the next level
> of abstraction, a keycode combined with modifier bits, e.g. "Letter A +
> Shift + Ctrl + Alt", or "Gray left arrow", or "Function Key 12", etc, plus
> all the complications regarding Num Lock, Alt-Gr, Alt-<keypad-digits>, etc
> etc.
> 
> How does this fit with UTF-8 keyboard mode?  I would assume that UTF-8
> must occur at an even higher level of abstraction.  If we are to allow for
> Linux-based terminal emulators, we need to provide an API for the application
> to get keypress info at any desired level of abstraction, and to "reget" the
> same event at a different level.  For example, the user presses the Euro key.
> What does the application see?
> 
> Are there still keycodes?  How can the application get at them?

The Linux keyboard driver either can act like a terminal emulator itself
(ASCII mode, UTF-8 mode), or it can be switched to various lower-level
modes. For instance, if you start the X server, the keyboard driver is
switched via an ioctl() into a raw mode. The X server completely
bypasses this way the terminal emulator that is built into the kernel
and remains completely uninfluenced by UTF-8 modes and other such
terminal emulator mechanisms. If you have an X server running, the xterm
and Xlib are the instances that have to convert key scan codes into
text, implement a UTF-8 mode, etc.

Linux man page:

KBD_MODE(1)                                           KBD_MODE(1)

NAME
       kbd_mode - report or set the keyboard mode

SYNOPSIS
       kbd_mode [ -a | -u | -k | -s ]

DESCRIPTION
       Without  argument,  kbd_mode  prints  the current keyboard
       mode (RAW, MEDIUMRAW or XLATE).  With  argument,  it  sets
       the keyboard mode as indicated:

       -s: scancode mode (RAW),

       -k: keycode mode (MEDIUMRAW),

       -a: ASCII mode (XLATE),

       -u: UTF-8 mode (UNICODE).

[...]

A simple UTF-8 keyboard mode has been in the Linux kernel since around
1994, but since most people use xterm instead of the console, UTF-8
didn't catch on much at that time. With xterm in XFree86 4.0 having now
a UTF-8 mode, with comprehensive fonts available, and with further UTF-8
infrastructure work on glibc, Xlib, etc. progressing, we now get to the
point where it becomes actually feasible to use UTF-8 on a broad
scale.

Markus

-- 
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org,  WWW: <http://www.cl.cam.ac.uk/~mgk25/>

-
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/lists/