Guardian Native C Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
Guardian Native C Library Calls (s) setlocale(3)
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.
POSIX Equivalent to C.
NULL Used to direct setlocale() to query the current internationalized environment and
return the name of the locale; does not change the locale.
If the locale parameter is set to the empty string (""), setlocale() checks the user’s environment
variables in the following order:
1. First it checks the value of the LC_ALL environment variable. If it is set, setlocale()
sets the specified category of the international environment to that value and returns the
string corresponding to the locale set (that is, the value of the environment variable, not
" ", the null string).
2. If the environment variable LC_ALL is not set or is set to the empty string, setlocale()
next checks the corresponding environment variable for the category specified or for all
categories, if the value of the category parameter is LC_ALL. If the environment vari-
able for the category is set, setlocale( ) sets the specified category of the international
environment to that value.
3. If the environment variable corresponding to the specified category is not set or is set to
the empty string, then setlocale() checks the LANG environment variable. If the LANG
environment variable is set, then setlocale() sets the category to the locale specified by
the LANG environment variable.
4. Lastly, if the LANG environment variable is not set or is set to the empty string, the set-
locale() function sets the category to the C locale.
If the locale parameter is the null pointer, the setlocale() function returns the name of the
program’s locale for the specified category and does not change the international environment.
If the locale specified by the locale parameter or by the environment variable is invalid, setlo-
cale() returns a null pointer and does not change the international environment.
EXAMPLES
1. The following example sets all categories in the international environment based on the
user’s environment variables.
(void)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 interna-
tional 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 environment variables.
2. The following example sets a specific category in the international environment to an
explicit locale.
(void)setlocale(LC_MESSAGES,"fr_FR.ISO8859-1");
527192-018 Hewlett-Packard Company 6−31