10.2 Locale Management in X
An internationalized X application begins in the same way as a
ANSI-C terminal-based internationalized program: with a call to
setlocale
. An X program, however, generally goes two
steps further.
Immediately after calling setlocale
, an
application should call XSupportsLocale()
to
determine if the Xlib implementation supports the current locale. This
function takes no arguments and return a Bool
. If
this function returns False
, an application will
typically print a “Locale not supported” message and exit.
After verifying that the locale is supported, an application
should call XSetLocaleModifiers()
. A “locale
modifier” can be thought of as an extension to the name of a locale; it
specifies more information about the desired localized behavior of an
application. R5 as shipped by MIT recognizes one locale modifier, used
to specify the input method (see Chapter 10) to be used for internationalized text
input for the locale.
XSetLocaleModifiers()
allows the programmer to
specify a list of modifiers (usually none) which will be concatenated
with a list of user-specified modifiers from an operating system
environment variable (XMODIFIERS
in POSIX). The
strings passed to XSetLocaleModifiers()
and set in
the XMODIFIERS
environment variable are a series of
concatenated “@category=value"
strings. Thus to specify that the “Xwnmo” input method should be used by
an application, a user might set the XMODIFIERS as follows:
setenv XMODIFIERS @im=_XWNMO
Example 10-1 shows code ...
Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.