Re: Japanese Display for gtk+-1.2.9



On Wed, 2 Nov 2005 14:43:57 +0800
Xyber Blue <xyberblue gmail com> wrote:

>>>Could you compile xmbcs.c after replacing setlocale()
>>>by _Xsetlocale() as following?
>
>After the said changes, the program successfully displayed the japanese
>characters.
>
>What does it mean??? What is the difference between the setlocale and
>_Xsetlocale???

_Xsetlocale() is an independent emulation of setlocale(),
for X11 internal use.

When X11R6 was implemented, the open group decided to use
ANSI locale model for localization of X11 system. But,
there were too many UNIX systems whose locale in libc are
broken, US-ASCII only, or 8bit only. To use multibyte
scripts like CJK on X11 on such systems, X11R6 introduced
an emulation functions for required ANSI locale functions.
_Xsetlocale(), _Xmblen(), _Xmbtowc(), _Xmbstowcs(),
_Xwctomb() and _Xwcstombs() were written for internal use.

When X11 is built with -DX_LOCALE flag, these emulation
functions are built in libX11. If without -DX_LOCALE,
these emulation functions are not used, original functions
in libc (setlocale(), mblen(), ...) are used.

See /usr/X11R6/include/X11/Xlocale.h. Even if -DX_LOCALE
is on, the emulated functions are not published, but
setlocale() is replaced by _Xsetlocale() by cpp hooking.
Keep it in mind: _Xsetlocale() should not be called explicitly.

Your problem is caused by the inconsistency of locale
handlers: X11 is built with -DX_LOCALE, but gtk+-1.2.9
is built without -DX_LOCALE.

In your X11, locale related functions expects that
the internal variables are initalized by _Xsetlocale()
in lib/X11/SetLocale.c. If they are not initialized,
their default values are tuned as if LANG=C.

In your gtk+-1.2.x, the locale handler is written in
gdk_set_locale() in gdkim.c. It calls setlocale().
I think, your gtk+-1.2.9 calls setlocale() in libc,
instead of _Xsetlocale().

As a result, although locale functions in libc are correctly
set to LANG=ja_JP by calling setlocale(), X11 does not use
them at all and uninitialized emulation functions in LANG=C
mode.

--

In summary, there are 2 solutions.

A) Rebuilding X11 without -DX_LOCALE
B) Rebuilding gtk+-1.2.x with -DX_LOCALE

Although I think X_LOCALE is fantastic system, I recommend A.
Because, there are too many "modern" applications that the
developer never test with -DX_LOCALE. In fact, most of Linux
distriburions are shipped with X11 built without -DX_LOCALE.
If using B solution, you may find many many sucking bugs that
the most Linux developer never found. In addition, recently
X_LOCALE functionalities has not been maintained well (especially
in XFree86 team products).

--

Why your X11 is built with -DX_LOCALE? I don't know.
I'm afraid the imake configuration files in xc/config/cf
doesn't know about FR-V processor, so configuration is
falled back into ancient Linux in libc5 era: whose locale
is broken and X_LOCALE is required for CJK.



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