On Thu, 18 Jan 2001, Dmitry Timoshkov wrote:

> "Francois Gouget" <[EMAIL PROTECTED]> wrote:
> 
> >    Well, I'm not in France but I do sometimes use my qwerty keyboard in
> > 'US-International' mode so that I can get some of these French
> > characters... via dead-keys. Of course it seems like half the Unix
> > applications don't support dead keys and the other half don't support
> > accents.
> 
> Actually support for dead keys can be implemented now, since Alexandre
> added support for composite unicode characters. I even wrote several tests
> to prove the concept and do 2->1 and 1->2 character conversions in
> WideCharToMultiByte and MultiByteToWideChar. But I have some problems:
> 1. Actually I don't know how to generate dead key sequence that will
> modify next character, because cyrillic has no this "feature".

It's really not that hard... under Windoze, the keyboard driver keeps some
internal static variable that holds the last deadchar used (the last
deadchar fed to ToAscii/ToUnicode).

When a deadkey is given to ToUnicode, it stores the deadchar into its
static variable and returns -1 and the dead character. When the
TranslateMessage code sees a return value of -1, it generates a
WM_DEADCHAR using the returned character.

On the subsequent ToUnicode invocation, it sees that a deadchar has been
stored, and tries to combine it with the incoming character. If it's able
to combine them, it returns the combined character and the return value 1.
If not, it returns both the uncombined dead character and the incoming
character, and the return value 2. Also, it clears the static variable, of
course...

TranslateMessage does send two WM_CHARs when ToAscii/ToUnicode returns 2,
if I remember right, though this case is often accompanied by a beep under
Windows.

> 2. Accent characters in different code pages has different mappings to
> unicode characters. Perhaps we just have to create internal table with
> mapping [combining character in code page] -> [combining character in unicode]?

Since the last deadkey is stored by the keyboard driver, it should have
been possible to just use the X11 deadkey stuff instead of Unicode
composition, but whatever...


Reply via email to