HP-UX Reference (11i v2 07/12) - 3 Library Functions N-Z (vol 7)

s
setlocale(3C) setlocale(3C)
NAME
setlocale( ), getlocale( ) - set and get the locale of a program
SYNOPSIS
#include <locale.h>
char *setlocale(int category, const char *locale);
struct locale_data *getlocale(int type);
Obsolescent Interfaces
int setlocale_r(int category, const char *locale, char *buffer,
int buflen);
int getlocale_r(int type, struct locale_data *ld);
DESCRIPTION
The setlocale() function sets, queries, or restores the aspect of a program’s locale that is specified by
the category argument. A program’s locale refers to those areas of the program’s Native Language Support
(NLS) environment for which the following values of category have been defined:
LC_ALL Affects behavior of all categories below, as well as all nl_langinfo(3C) items.
LC_COLLATE Affects behavior of regular expressions and the NLS string collation functions
(see string(3C), and regexp(5)).
LC_CTYPE Affects behavior of regular expressions, character classification, and conversion
functions (see ctype(3C), wctype(3C), wconv(3C), conv(3C), and regexp(5)). The
LC_CTYPE category also affects the behavior of all routines that process multi-
byte characters (see multibyte(3C)).
LC_MESSAGES Affects the language in which messages are displayed and the processing of
affirmative and negative responses (see catopen(3C) and nl_langinfo(3C)).
LC_MONETARY Affects behavior of functions that handle monetary values (see localeconv(3C)
and strfmon(3C)).
LC_NUMERIC Affects handling of the radix character in the formatted input/output functions
(see printf(3S), scanf(3S) and vprintf(3S)) and the string conversion functions
(see ecvt(3C) and strtod(3C)). LC_NUMERIC also affects the numeric values
found in the localeconv structure.
LC_TIME Affects the behavior of time conversion functions (see getdate(3C), strftime(3C),
and strptime(3C)).
All nl_langinfo(3C) items are affected by the setting of one of the categories listed above. See langinfo(5) to
determine which categories affect each item.
The value of the locale argument determines the action taken by
setlocale() . locale is a pointer to a
character string.
Note that while
setlocale() can be called concurrently from multiple threads, the locale data struc-
tures that get updated are not protected against reads by other threads. Hence it is up to the application
developer to ensure proper synchronization when changing locales.
Setting the Locale of a Program
To set the program’s locale for category, setlocale() accepts one of the following values as the locale
argument: locale name, C, POSIX,or "" (the empty string). The actions prescribed by these values are
as follows:
locale name If locale is a valid locale name (see lang(5)), setlocale() sets that part of the
NLS environment associated with category as defined for that locale.
C If the value of locale is set to C, setlocale() sets that part of the NLS
environment associated with category as defined for the C locale (see lang(5)).
The C locale is the default prior to successfully calling setlocale() .
POSIX Same as C.
404 Hewlett-Packard Company − 1 − HP-UX 11i Version 2: December 2007 Update