setlocale(3C) setlocale(3C)
NAME
setlocale - set/query a program's locale
SYNOPSIS
#include <locale.h>
char *setlocale(int category, const char *locale);
DESCRIPTION
setlocale() selects the appropriate piece of the program's locale as
specified by the category and locale arguments. category may have the
following values: LCCTYPE, LCNUMERIC, LCTIME, LCCOLLATE,
LCMONETARY, LCMESSAGES and LCALL. These names are defined in the
locale.h header file. LCCTYPE affects the behavior of the character
handling functions (isdigit, tolower, etc.) and the multibyte charac-
ter functions (such as mbtowc() and wctomb()). LCNUMERIC affects the
decimal-point character for the formatted input/output functions and
the string conversion functions as well as the non-monetary formatting
information returned by localeconv [see localeconv(3C)]. LCTIME
affects the behavior of ascftime(), cftime(), getdate and strftime().
LCCOLLATE affects the behavior of strcoll() and strxfrm().
LCMONETARY affects the monetary formatted information returned by
localeconv. LCMESSAGES affects the behavior of gettxt(), catopen(),
catclose(), and catgets [see catopen(3C) and catgets(3C)]. LCALL
names the program's entire locale.
Each category corresponds to a set of databases which contain the
relevant information for each defined locale. The location of a data-
base is given by the following path, /usr/lib/locale/locale/category,
where locale and category are the names of locale and category,
respectively. For example, the database for the LCCTYPE category for
the "German" locale would be found in /usr/lib/locale/german/LCCTYPE.
The values "POSIX" or "C" for locale specify the default minimal envi-
ronment.
A value of "" for locale specifies that the locale should be taken
from environment variables. The order in which the environment vari-
ables are checked for the various categories is given below:
Category 1st Env. Var. 2nd Env. Var.
LCCTYPE: LCCTYPE LANG
LCCOLLATE: LCCOLLATE LANG
LCTIME: LCTIME LANG
LCNUMERIC: LCNUMERIC LANG
LCMONETARY: LCMONETARY LANG
LCMESSAGES: LCMESSAGES LANG
Page 1 Reliant UNIX 5.44 Printed 11/98
setlocale(3C) setlocale(3C)
At program startup, the equivalent of
setlocale(LCALL, "C")
is executed. This has the effect of initializing each category to the
locale described by the environment "C".
If a pointer to a string is given for locale, setlocale() attempts to
set the locale for the given category to locale. If setlocale()
succeeds, locale is returned. If setlocale() fails, a null pointer is
returned and the program's locale is not changed.
For category LCALL, the behavior is slightly different. If a pointer
to a string is given for locale and LCALL is given for category, set-
locale() attempts to set the locale for all the categories to locale.
The locale may be a simple locale, consisting of a single locale, or a
composite locale. A composite locale is a string beginning with a /
followed by the locale of each category separated by a /. If setlo-
cale() fails to set the locale for any category, a null pointer is
returned and the program's locale for all categories is not changed.
Otherwise, locale is returned.
A null pointer for locale causes setlocale() to return the current
locale associated with the category. The program's locale is not
changed.
FILES
/usr/lib/locale/C/LCCTYPE - LCCTYPE
/usr/lib/locale/C/LCNUMERIC - LCNUMERIC
/usr/lib/locale/C/LCTIME - LCTIME
/usr/lib/locale/C/LCCOLLATE - LCCOLLATE
/usr/lib/locale/C/LCMESSAGES - LCMESSAGES
/usr/lib/locale/locale/category
files containing the locale specific information for each locale
and category
SEE ALSO
ctime(3C), ctype(3C), getdate(3C), gettxt(3C), localeconv(3C),
mbtowc(3C), strcoll(3C), strftime(3C), strtod(3C), strxfrm(3C),
wctomb(3C), printf(3S), environ(5).
Page 2 Reliant UNIX 5.44 Printed 11/98