XLocale(3X11) X11R5 XLocale(3X11)NAMEXLocale - all functions to access locale database
SYNOPSIS
#include "Xlocaleint.h"
int
_Xmbtype(xlocale)XLocale xlocale;
The _Xmbtype() returns the codeset type of the locale. Two types will
be returned:
CDS_STATELESS -- state-independent codeset
CDS_STATEFUL -- state-dependent codeset
If application never calls the setting locale, the function returns -1,
no locale has been set. With the _Xmbtype you can check if there is
locale.
int
_Xmbcsnum(xlocale)XLocale xlocale;
The _Xmbcsnum returns the number of charsets of the locale.
_CSID
_Xmbcsid(xlocale, mbstr)
Xlocale xlocale;
unsigned char *mbstr;
The function returns the charset id "CSi" of the multibyte character
encoded in the current locale. The multibyte character is stored in
the null-terminated string "mbstr". The charset id is ordered from
positive number 0. The CSi is defined to a constant "i", e.g, CS1 is
constant 1.
The _Xmbcsid returns constant ND for any error of the multibyte charac‐
ter which maybe wrong code, or maybe terminated unexpectly.
For state-dependent codeset, _Xmbcsid keeps the track of the current
locking shift-state. In other word only this function _Xmbcsid would
change the current state. When the mbstr is passed as a NULL pointer,
the _Xmbcsid sets the initial state.
_Xmbcsid(xlocale, NULL)
int
_Xmblen(xlocale)XLocale xlocale;
The _Xmblen returns the number of bytes of the current charset in the
xlocale. The returned value is zero for wrong charset id.
char *
_Xmbdsg(xlocale)XLocale xlocale;
This function is for state-dependent codeset only. The _Xmbdsg returns
the designation of this charset. The NULL returned is for wrong csid.
The returned string is owned by the locale, do not change or free it.
int
_Xmbdlen(xlocale, mbstr)
Xlocale xlocale;
unsigned char *mbstr;
This function is for state-dependent codeset only. If the mbstr con‐
tains a complete designation sequence, the _Xmbdsg returns the length
of the sequence; otherwise returns zero. The mbstr is null-terminated
string.
int
_Xmbfsnum(xlocale)XLocale xlocale;
The _Xmbfsnum returns the number of font charsets of the current
locale. This number is different from _Xmbcsnum().
char *
_Xmbfsname(xlocale)XLocale xlocale;
The _Xmbfsname returns the charset name with the current charset. The
name is form of CharsetRegistry-CharsetEncoding registered by X in the
definition of XLFD. The NULL returned is for the wrong charset. The
returned string is owned by the current locale, so do not change and
free this data.
int
_Xmbfslen(xlocale)XLocale xlocale;
The _Xmbfslen returns the number of bytes of the current charset of
font encoding. The zero returned is for wrong charset.
wchar
_Xmbfswf(xlocale, csid) XLocale xlocale;
int csid;
The _Xmbfswf returns the woffset of the font charset id. This woffset
is for the 4-byte wchar encoding. The negative value -1 returned is
for wrong csid.
char *
_Xmbfsdsg(xlocale)XLocale xlocale;
The _Xmbfsdsg returns the designation sequence, i.e., escape sequence
of font charset which is registered by X in the "Compound Text Encod‐
ing, Version 1.1". The returned value is owned by the locale, do not
free or change it. The NULL returned is for wrong charset.
int
_Xmbctocsc(xlocale, mbstr, cscode)
XLocale xlocale;
unsigned char *mbstr;
unsigned int *cscode;
The _Xmbctocsc converts codepoint of multibyte character to codepoint
of charset. The csid is it's charset id. The converted code is stored
in the cscode. If wrong codepoint, use the first codepoint of csid as
default, and return negative value. if correct, return 0 meaning Suc‐
cess. The _Xmbctocsc always supposes that the mbstr points to a code‐
point, not shift-state sequence if codeset is state-dependent. The
caller should note this, otherwise the _Xmbctocsc treats it as wrong
codepoint.
int
_Xcsctombc(xlocale, cscode, code)
XLocale xlocale;
unsigned int cscode;
unsigned int *code;
The _Xcsctombc does the reverse conversion of _Xmbctocsc.
char *
_Xsetlocale(locale_category, locale_name)
int locale_category;
char *locale_name;
The _Xsetlocale sets the current locale for the specified category. If
the operation was successful, _Xsetlocale returns a pointer to the cur‐
rent locale name for the category If the category is invalid or the
locale is not supported in the system, _Xsetlocale returns a NULL
pointer. The returned locale name is owned by the system locale, do
not change or free it.
The category is defined to one of the following:
LC_CTYPE
LC_ALL
The locale name is allowed to the form:
NULL
""
string
The value NULL means to query the current locale name, and _Xsetlocale
returns the locale name string.
The empty string sets the implementation-dependent locale. It examines
the environment $LANG. If ${LANG} is set and contains the name of a
valid locale, that value is used to set category. If the value is still
not obtained, _Xsetlocale sets the category to C-language "C" and
return the locale name. The C locale is ASCII codeset.
The locale name is accepted to the following form:
language[_territory[.codeset]]
The language and territory are country codes defined in ISO 639 and ISO
3166.
SEE ALSO
X/Open Portability Guide, Volume 3, XSI Internationalization.
IS0 639, ISO 3166.
XLocale(3X11)