NAME
setlocale - Changes or queries the program's entire current
locale or portions thereof
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <locale.h>
char *setlocale (
int category,
const char *locale );
PARAMETERS
category Specifies a value from the locale.h header file
that names the program's entire locale or a por-
tion thereof.
locale Points to a string defining the locale.
DESCRIPTION
The setlocale() function selects the appropriate portion of
the program's locale as specified by the category and locale
parameters. The setlocale() function can be used to change
or query the program's entire current locale or portions
thereof. The LC_ALL value for the category parameter names
the entire locale; the other values name only a portion of
the program locale, as follows:
LC_COLLATE
Affects the behavior of the strcoll() and
strxfrm() functions.
LC_CTYPE Affects the behavior of the character handling
functions (except for the isdigit() and isxdigit()
functions) and the multibyte functions.
LC_MONETARY
Affects the monetary formatting information
returned by the localeconv() function.
LC_NUMERIC
Affects the decimal-point character for the for-
matted input/output functions and the string
conversion functions, as well as the nonmonetary
formatting information returned by the
localeconv() function.
LC_TIME Affects the behavior of the strftime() function.
The behavior of the language information function defined in
the nl_langinfo() function is also affected by settings of
the category parameter.
The locale parameter points to a character string containing
the required setting of the category parameter. The follow-
ing values of locale are defined for all settings of
category:
C Specifies the minimal environment for C-language
translation. If setlocale() is not invoked, the C
locale is the default. Operational behavior
within the C locale is defined separately for each
interface function that is affected by the locale
string.
``'' Specifies a native environment, corresponding to
the value of the associated environment variables.
In all cases, the setlocale() function first
checks the value of the corresponding environment
variable and if valid, setlocale() sets the speci-
fied category of the international environment to
that value and returns the string corresponding to
the locale set (that is, the value of the environ-
ment variable, not ""). If the value is invalid,
setlocale() returns a null pointer and the inter-
national environment is not changed by this func-
tion call.
If the environment variable corresponding to the
specified category is not set or is set to the
empty string, and the LANG environment variable is
set and valid, then setlocale() sets the category
to the corresponding value of LANG. If the LANG
environment variable is not set, the setlocale()
function uses a system-wide default.
To set all categories in the international
environment, the setlocale() function is invoked
in the following manner:
setlocale (LC_ALL, "");
To satisfy this request, the setlocale() function
first checks all the environment variables. If
any environment variable is invalid, setlocale()
returns a null pointer and the international
environment is not changed by this function call.
If all the relevant environment variables are
valid, setlocale() sets the international
environment to reflect the values of the environ-
ment variables. The categories are set in the
following order:
LC_CTYPE
LC_COLLATE
LC_TIME
LC_NUMERIC
LC_MONETARY
Using this scheme, the categories corresponding to the
environment variables will override the value of the LANG
environment variable for a particular category.
NULL Used to direct setlocale() to query the current
internationalized environment and return the name
of the locale.
Note that a locale can only be changed once.
NOTES
The setlocale() function is not threadsafe, and does not
have any threadsafe equivalent. This means that the setlo-
cale() function should only be called once in the main part
of a program, before any threads are created.
AES Support Level:
Full use (setlocale())
RETURN VALUES
If a pointer to a string is given for the locale parameter
and the selection can be honored, the setlocale() function
returns the string associated with the specified category
parameter for the new locale. If the selection cannot be
honored, a null pointer is returned and the program locale
is unchanged.
If a null pointer for the locale parameter causes the setlo-
cale() function to return the string associated with the
category parameter for the program current locale, the pro-
gram locale is unchanged.
The string returned by the setlocale() function is such that
a subsequent call with that string and its associated
category restores that part of the program locale. The
string returned is not modified by the program, but can be
overwritten by a subsequent call to the setlocale() func-
tion.
RELATED INFORMATION
Functions: atof(3), ctype(3), jctype(3), localeconv(3),
nl_langinfo(3), printf(3), scanf(3), strftime(3), string(3)
Acknowledgement and Disclaimer