|
|
char *setlocale(int category, const char *locale);
LC_CTYPE affects the behavior of character handling functions such as isdigit.3c and tolower.3c and multibyte character functions such as mbtowc.3c and wctomb.3c
LC_NUMERIC affects the decimal point character and thousands separator character for the formatted input/output functions and string conversion functions.
LC_TIME affects the date and time format as delivered by ascftime.3c cftime.3c getdate.3c strftime.3c and strptime.3c
LC_COLLATE affects the sort order produced by collating functions such as strcoll (3C) and strxfrm.3c
LC_MONETARY affects the monetary formatted information returned by localeconv.3c
LC_MESSAGES affects the behavior of messaging functions such as dgettext.3c gettext.3c and gettxt.3c
A value of "C" for locale specifies the traditional UNIX system behavior. At program startup, the equivalent of
is executed. This has the effect of initializing each category to the locale described by the environment "C".
A value of "" for locale specifies that the locale should be taken from environment variables. The order in which the environment variables are checked for the various categories is given below:
Category 1st Env. Var. 2nd Env. Var. 3rd Env. Var
LC_CTYPE: LC_ALL LC_CTYPE LANG
LC_COLLATE: LC_ALL LC_COLLATE LANG
LC_TIME: LC_ALL LC_TIME LANG
LC_NUMERIC: LC_ALL LC_NUMERIC LANG
LC_MONETARY: LC_ALL LC_MONETARY LANG
LC_MESSAGES: LC_ALL LC_MESSAGES LANG
If a pointer to a string is given for locale, setlocale() attempts to set the locale for the given category to locale. If setlocale() succeeds, locale is returned. If setlocale() fails, a null pointer is returned and the program's locale is not changed.
For category LC_ALL, the behavior is slightly different. If a pointer to a string is given for locale and LC_ALL is given for category, setlocale() attempts to set the locale for all the categories to locale. The locale may be a simple locale, consisting of a single locale, or a composite locale. If the locales for all the categories are the same after all the attempted locale changes, setlocale() will return a pointer to the common simple locale. If there is a mixture of locales among the categories, setlocale() will return a composite locale.
If setlocale() fails to set the locale for any category, a null pointer is returned and the program's locale for all categories is not changed. Otherwise, locale is returned.
A null pointer for locale causes setlocale() to return the current locale associated with the category. The program's locale is not changed.
+---------------+-------------------------+ |ATTRIBUTE TYPE | ATTRIBUTE VALUE | +---------------+-------------------------+ |MT-Level | MT-Safe with exceptions | |CSI | Enabled | +---------------+-------------------------+
It is the user's responsibility to ensure that mixed locale categories are compatible. For example, setting LC_CTYPE=C and LC_TIME=ja (where ja indicates Japanese) will not work, because Japanese time cannot be represented in the ``C'' locale's ASCII codeset.
Internationalization functions by setlocale() are supported only when the dynamic linking version of libc has been linked with the application. If the static linking version of libc has been linked with the application, setlocale() can handle only C and POSIX locales.
|
|
Created by unroff & hp-tools. © by Hans-Peter Bischof. All Rights Reserved (1997).
Last modified 07/October/97