| Kip Rugger 2006-06-25, 7:06 pm |
| Donal K. Fellows <donal.k.fellows@manchester.ac.uk> wrote:
>
>
>Kip Rugger wrote:
>[...]
>
>That's a bit like saying that Chewbacca can be considered a Hutt (for
>this explanation). :-) Keyboards are definitely not utf-8 devices.
>Nothing so simple at all. Keyboard input consists of a sequence of one
>or more events (the first[*] of which is a KeyEvent) with some very
>oddly encoded data inside them. Tk then has to pick apart what is going
>on (non-trivial!) and convert to utf-8 before handing it off to the
>higher levels where scripts are run. Input method handling makes this
>amazingly more difficult...
>
>Donal.
>[* XIM is nasty. Very very nasty. ]
I was trying to say that _logically_, the keyboard can be considered
as a utf-8 source, since under suitable mappings it can deliver any
character in the utf-8 space. I am not so stupid as to think the
hardware is actually delivering utf-8 characters, thank you very much.
What I believe happened is that the Tk support for utf-8 predates the
support in X. In particular, Tk uses XmbLookupString and not
Xutf8LookupString. The latter was likely not available when the Tk
support was written.
This creates a dependency on the current locale as described by the
OP. It also prevents keyboard remapping from working, because the Tk
XmbLookupString uses an input context bound to the startup-time
locale. It would be better to let X handle this entirely (by using
Xutf8LookupString) so as to remove this unwanted dependency. I
suspect this is what the apps in Andreas's list (opera, firefox,
gedit, gvim) are doing, and why they "support" keyboard remapping
while Tk does not.
The XIM* functions are part of the larger Xkb extension of X. There
is a history of overdesigned extensions in X (xim, pex5) that were too
complicated to gain any usage, and are essentially dead. Xkb has some
of this, but as you pointed out, the problem it is trying to solve is
also somewhat intransigent. The real defect with Xkb is the lack of
good documentation, which is why you ultimately have to read the
source code.
|