Re: [Draft] Writing i18n apps with glibc 2.2
Hi Roger, here are some of my thoughts on your draft.
Regards,
Rigel
On Sat, Oct 14, 2000 at 06:06:08PM +1100, Roger So wrote:
>
> locales; it is now more POSIX compliant. [is it?] However, as a result,
> the semantics of many library calls have changed. The following is a
I'm not aware any semantic change of any library call. Could you elobrate?
> 1. Don't use environment variables to determine locale settings. In
> particular, do NOT use the value returned by setlocale(3) to
> determine the current locale's encoding! Instead, use
> nl_langinfo(3) for this purpose.
Good point. However I don't think it's glibc 2.2 issue. Actually if you stick
with glibc only this is not a very big issue, because you always know how
the locales are named (well, kind of). It's a serius issue when you want your
program also runs on other unix systems with their native C library. That's
when the naming conventions becomes wild. So if portability is a concern,
nl_langinfo should be used no matter what C library you work with.
> 2. isprint(3) vs. iswprint(3): To test whether a byte is printable, use
> iswprint(3). To test whether a character is printable, use
> isprint(3). Take 0xA7DA ('我' in Big5) for example: iswprint(0xA7),
No, please don't. You should continue to use isprint to test whether a byte
is printable. The iswprint is only supposed to work with widechar. iswprint
was not available in glibc 2.1.x, also added to glibc2.2 are whole bunch of
isw* functions and widechar I/O functions (such as wprintf). These functions
are long waited, just ask those mutt developers!
>
> [Anything else?]
>
Just a small thing. A new LC_CTYPE class "hanzi" was added in glibc 2.2
locale (both zh_CN and zh_TW have it, zh_HK doesn't though). It currently
contains all the unicode unihan characters. I don't know how useful this
is (your comments on this are welcomed). In case some one is interested in
this, here is a sample implementation of "iswhanzi(wchar_t wc)"
#include <wchar.h>
#include <wctype.h>
int iswhanzi(wchar_t wc)
{
return iswctype (wc, wctype("hanzi"));
}
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Reply to: