11.10 Getting Composed Text
Prior to R5, XLookupString() was used to
convert the keycode returned in a KeyPress event into a KeySym and
further into a character string that could be passed to the X text
drawing functions. Unfortunately, this function only works for the
Latin-1 charset. To support internationalization in a limited way, there
were alternate LookupString functions in the Xmu
library: XmuLookupLatin2(),
XmuLookupJISX0201(),
XmuLookupGreek(), etc. In R5, these have been
superseded by XmbLookupString() and
XwcLookupString(). These functions are identical
except in the type of string they return: the Xmb
version returns a multi-byte string of char, and
Xwc version returns a wide-character string of
wchar_t. In both cases the string will be encoded as
appropriate for the locale of the IC.[47]
Whenever a KeyPress event is delivered to an
application that is performing internationalized text input, the
application should use that event in a call to
XmbLookupString() or
XwcLookupString(). (Note that
KeyRelease events should not be passed to these
functions—they will result in undefined behavior.) The application
should not expect that each call to
Xmb/XwcLookupString() will return a string. Depending
on the complexity of the input method in use, a user may type many
keystrokes before any composed input is ready for the application.
Neither should the application expect that
Xmb/XwcLookupString() will return a single character at a time—in some input methods a user may type ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access