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

Re: Testing for UTF-8 tty mode



>for extracting the charset from LC_CTYPE,
>
>#include <langinfo.h>
>  charset = nl_langinfo(CODESET);


 It is necessary to note that it not a POSIX.

 <langinfo.h> and nl_langinfo(3) defined only in XPG3/XPG4
and in Unix'99, Single Unix 2 and SVID(?).

 Thus many *NIX systems have not these functions.
FreeBSD, for example.

 However, there is another solution.You must ALWAYS give
a comlete, long locale name as defined in POSIX :

           language_TERRITORY.Codeset

 As an example we consider variables MANPATH or NLSPATH :
http://www.sensi.org/~alec/man/man_e/nlspath.html

 These variables can contain substitutions:

%L  The value of the LC_MESSAGES category. 
%l  The language element from the LC_MESSAGES category. 
%t  The territory element from the LC_MESSAGES category. 
%c The codeset element from the LC_MESSAGES category. 
%% A single % character. 

 So, for LANG="ru_RU.KOI8-R" we'll have:

%L = ru_RU.KOI8-R
%l = ru
%t = RU
%c = KOI8-R

 In our case, it will be LANG="ru_RU.UTF-8"


 The open sources of catopen(3) you can find in GNU libc 2
or in Kee Hinckley's <nazgul@alfalfa.com> msgcat package.


--
-=AV=-

-
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/lists/