#include <locale.h>
char *setlocale(category, locale) int category; char *locale;
int nl_init(lang) char *lang;
setlocale() selects the appropriate piece of the program's locale as specified by category, and may be used to change or query the program's international environment. The entire locale may be changed by calling setlocale() with category set to LC_ALL. The other possible values for category query or change only a part of the program's complete international locale:
The locale argument is a pointer to a character string containing the required setting of category. The following preset values of locale are defined for all settings of category:
At program startup, the equivalent of:
If the environment variable corresponding to the specified category is not set or is set to the empty string, setlocale() will examine the LANG environment variable. If both the LANG environment variable, and the environment variable corresponding to the specified category are not set or are set to the empty string, then the LC_default environment variable is examined. If this contains a valid setting, then the category is set to the value of LC_default. If the LANG environment variable is set and valid this will set the category to the corresponding value of LANG. If LC_default is not set, then setlocale() returns that category to the default "C" locale.
To set all categories in the international environment, setlocale() is invoked in the following manner:
setlocale (LC_ALL, "" );
To satisfy this request, setlocale() first checks all the relevant environment variables LC_CTYPE, LC_COLLATE, LC_TIME, LC_NUMERIC, LC_MONETARY, LC_MESSAGES. If any one of these relevant environment variables is invalid, this call to setlocale() will return a NULL pointer, and the international environment will not be changed. If all the relevant environment variables are valid, setlocale() sets the international environment to reflect the values of the environment variables. The categories are set in the following order:
LC_CTYPE LC_COLLATE LC_TIME LC_NUMERIC LC_MONETARY LC_MESSAGES
Using this scheme, the categories corresponding to the environment variables will override the value of the LANG and LC_default environment variables for a particular category.
nl_init() is equivalent to
setlocale(LC_ALL, "");
and is supplied for compatibility with X/Open XPG2.
If a valid string is given for the locale parameter, and the selection can be honored, setlocale() returns the string associated with the specified category for the new locale. If the selection cannot be honored, setlocale() returns a null pointer and the program's locale is not changed.
A NULL pointer for locale causes setlocale() to return the string associated with the category for the program's current locale; the program's locale is not changed. The string contains information relating to each piece part of the whole international environment. This inquiry can fail by returning a null pointer if any category is invalid.
The string returned by such a setlocale() call is such that a subsequent call with the string and its associated category will restore that part of the program's locale. The string returned by:
is such that in a subsequent call:
will reset each and every category to the state when the string was first returned. The string returned must not be modified by the program, but will be overwritten by a subsequent call to setlocale().
setlocale() returns a null pointer if a relevant environment variable has an invalid setting. setlocale() also returns a null pointer if category is invalid.
Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97