Subject: Re: Restart: better XI18N future API
To: None <i18n@XFree86.Org>
From: Noriyuki Soda <soda@sra.co.jp>
List: tech-x11
Date: 12/22/2000 17:38:19
>>>>> On Thu, 21 Dec 2000 16:01:55 -0800 (PST), hiura@unicode.org said:
> Here is the consideration.
> If XmbDrawString takes "encoding" parameter, such as
> XmbDrawString(....., encoding, string, ..), it perfoms
> the same as
> Xutf8DrawString(....., string, ..)
> when the encoding parameter is set to UTF-8.
> Let's call XmbDrawString(....., encoding, string, ..) as
> XembDrawString, stands for X encoded multi-byte DrawString for
> now for the sake of discussion.
I believe this is not good API as I posted previous mail.
Because Output Context is encoding dependent, thus, passing encoding
parameter to XmbDrawString breaks current abstraction about output
context. (What happens when a string which cannot be displayed by the
fontset parameter passed to the XembDrawString?)
And because of above reason, implementation is hard, and cannot be
right.
I think the right way to solve multi-thread/multi-locale problem
is to create three APIs which have locale parameter (not encoding
parameter).
- XLocaleNameOfEncoding(locale_name, encoding_name)
This is generalized version of XFree86UTF8Locale() which I wrote
before. This function returns locale name which correspond to
locale_name parameter, but changes its encoding to encoding_name
parameter. The first parameter locale_name is Operating System
dependent. The second parameter encoding_name should be
standardized by X Consortium. The return value is Operating System
dependent.
The implementation of this function should be Operating System
dependent unless X_LOCALE is used.
Note that this function may return NULL, when the encoding_name
is not supported on the Operating System.
e.g.
XLocaleNameOfEncoding("en_US.ISO8859-1", "UTF-8") -> "en_US.UTF-8"
XLocaleNameOfEncoding("C", "UTF-8") -> "en_US.UTF-8"
XLocaleNameOfEncoding("C", "eucJP") -> "ja_JP.eucJP"
XLocaleNameOfEncoding("zh_CN.eucCN", "UTF-8") -> "zh_CN.UTF-8"
XLocaleNameOfEncoding("ja_JP.UTF-8", "eucJP") -> "ja_JP.eucJP"
- XOpenIMOfLocale(display, rdb, res_name, res_class, locale_name)
This is a variant of XOpenIM() which has explicit locale_name
parameter.
- XOpenOMOfLocale(display, rdb, res_name, res_class, locale_name)
This is a variant of XOpenOM() which has explicit locale_name
parameter.
Thus, a program which needs to display unicode string can use
XmbDrawString and its variants with UTF-8 Output Context created by
XOpenOMOfLocale(....., XLocaleNameOfEncoding(setlocale(LC_CTYPE,
NULL), "UTF-8"));
This only introduces three APIs, and the implementations of the three
APIs are trivial for anyone who have clue.
--
soda