Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)

setlocale(3) Guardian Native C Library Calls Reference Manual
C Species 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 dened 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 users 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 specied 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 specied 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 specied category of the international
environment to that value.
3. If the environment variable corresponding to the specied 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 specied 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
programs locale for the specied category and does not change the international environment.
If the locale specied 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
users environment variables.
(void)setlocale (LC_ALL, "");
To satisfy this request, the setlocale() function rst 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 reect the values of
the environment variables.
2. The following example sets a specic category in the international environment to an
explicit locale.
(void)setlocale(LC_MESSAGES,"fr_FR.ISO8859-1");
616 Hewlett-Packard Company 527192-005