SETLOCALE(3C-POSIX) RISC/os Reference Manual SETLOCALE(3C-POSIX)
NAME
setlocale - set or query program locale
SYNOPSIS
#include <locale.h>
char *setlocale(category, locale)
int category;
char *locale;
DESCRIPTION
setlocale selects the piece of the program's locale speci-
fied by category and locale. category may have one of the
following values, which are defined in <locale.h>:
LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY,
LC_ALL.
LC_CTYPE affects the behavior of the character handling
functions (e.g. isdigit, tolower). LC_NUMERIC affects the
decimal-point character for the formatted input and output
functions and the string conversion functions. LC_TIME
affects the behavior of asctime, cftime, getdate, and
strftime. LC_COLLATE and LC_MONETARY are currently unused
by the library.
LC_ALL names the program's entire locale.
Each category corresponds to a set of databases that contain
the relevant information for each defined locale. The loca-
tion of a database is given by the path
/posix/lib/locale/locale/category, where locale and category
are the names of locale and category, respectively. For
example, the database for the LC_CTYPE category for the
"german" locale would be found in
/posix/lib/locale/german/LC_CTYPE.
If locale has the value "C", the default environment is
used. If locale has the value "", the locale is taken from
environment variables. The order in which the environment
variables are checked for the various categories is as fol-
lows:
Category 1st Env. Variable 2nd
LC_CTYPE LC_CTYPE LANG
LC_NUMERIC LC_NUMERIC LANG
LC_TIME LC_TIME LANG
LC_COLLATE LC_COLLATE LANG
LC_MONETARY LC_MONETARY LANG
If both the first and second environment variable are not
defined or have NULL values, then the default ("C") locale
is used.
Printed 1/15/91 Page 1
SETLOCALE(3C-POSIX) RISC/os Reference Manual SETLOCALE(3C-POSIX)
When a program is started, the locale is initialized to the
default ("C") environment.
If locale is a pointer to a string, setlocale attempts to
set the locale for the given category to locale. If this is
successful, locale is returned. Otherwise, a NULL pointer
is returned and the program's locale is not changed. setlo-
cale can only fail when setting the locales for LC_CTYPE and
LC_NUMERIC. Invalid locales for the other categories are
checked by the functions which use the locale information.
For example, the locale for LC_TIME is checked by strftime.
If locale is a NULL pointer, setlocale returns the current
locale associated with the category and the program's locale
is not changed. If category is LC_ALL, and the categories
do not have the same locale, a NULL pointer is returned and
each category must be queried individually.
FILES
/posix/lib/locale/C/LC_CTYPE - LC_CTYPE database for the C locale
/posix/lib/locale/C/LC_NUMERIC - LC_NUMERIC database for the C locale
/posix/lib/locale/C/LC_TIME - LC_TIME database for the C locale
/posix/lib/locale/C/LC_COLLATE - LC_COLLATE database for the C locale
/posix/lib/locale/C/LC_MONETARY - LC_MONETARY database for the C locale
/posix/lib/locale/locale/category - files containing the category
information for locale
SEE ALSO
atof(3), ctype(3), printf(3S), strftime(3-POSIX).
Page 2 Printed 1/15/91