The <locale.h>
header file declares two functions and
one type and defines several macros.
struct lconv
char *decimal_point; /* "." */ char *thousands_sep; /* "" */ char *grouping; /* "" */ char *int_curr_symbol; /* "" */ char *currency_symbol; /* "" */ char *mon_decimal_point; /* "" */ char *mon_thousands_sep; /* "" */ char *mon_grouping; /* "" */ char *positive_sign; /* "" */ char *negative_sign; /* "" */ char int_frac_digits; /* CHAR_MAX */ char frac_digits; /* CHAR_MAX */ char p_cs_precedes; /* CHAR_MAX */ char p_sep_by_space; /* CHAR_MAX */ char n_cs_precedes; /* CHAR_MAX */ char n_sep_by_space; /* CHAR_MAX */ char p_sign_posn; /* CHAR_MAX */ char n_sign_posn; /* CHAR_MAX */
These members are described under the localeconv
function in this section.
NULL
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MONETARY
LC_NUMERIC
LC_TIME
setlocale
function.
char *setlocale(int category, const char
*locale);
The following values can be specified for the category argument:
strcoll
and strxfrm
functions.
localeconv
function.
localeconv
function.
strftime
function.
The following values can be specified for the locale argument:
LANG
environment
variable is used. If LANG
is not set, an error
is returned.
At program startup, the equivalent of the following is executed:
setlocale(LC_ALL, "C");
The setlocale
function returns one of the following:
setlocale
returns a pointer to 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.
setlocale
returns a pointer to the string
associated with the category for the program's
current locale. The program's locale is not changed.
In either case, the returned pointer to the string is such that
a subsequent call with that string value and its associated
category will restore that part of the program's locale. This
string must not be modified by the program, but it can be
overwritten by subsequent calls to setlocale
.
struct lconv *localeconv(void);
struct
lconv
with values appropriate for formatting numeric
quantities according to the rules of the current locale.
The structure members with type char *
are pointers
to strings, any of which (except decimal_point
) can
point to "", which indicates that the value has zero length or
is not available in the current locale. Structure members of type
char
are nonnegative numbers, any of which can be
CHAR_MAX
to indicate that the value is not available
in the current locale. Structure members include the following:
char *decimal_point
char *thousands_sep
char *grouping
char *int_curr_symbol
char *currency_symbol
char *mon_decimal_point
char *mon_thousands_sep
char *mon_grouping
char *positive_sign
char *negative_sign
char int_frac_digits
char frac_digits
char p_cs_precedes
currency_symbol
precedes
the value for a nonnegative formatted monetary quantity;
set to 0 if the currency_symbol
follows the
value.
char p_sep_by_space
currency_symbol
is
separated by a space from the value for a nonnegative
formatted monetary quantity; set to 0 if there is no
space.
char n_cs_precedes
currency_symbol
precedes
the value for a negative formatted monetary quantity;
set to 0 if the currency_symbol
follows the
value.
char n_sep_by_space
currency_symbol
is
separated by a space from the value for a negative
formatted monetary quantity; set to 0 if there is no
space.
char p_sign_posn
positive_sign
for a nonnegative formatted
monetary quantity.
char n_sign_posn
negative_sign
for a negative formatted
monetary quantity.
The elements of grouping
and mon_
grouping
are interpreted according to the following:
CHAR_MAX
-no further grouping is to be
performed.
The value of p_sign_posn
and n_sign_
posn
is interpreted as follows:
currency_
symbol
currency_symbol
currency_symbol
currency_symbol
currency_symbol
The localeconv
function returns a pointer to
the filled in structure. The structure must not be modified
by the program, but might be overwritten by subsequent calls
to localeconv
or to setlocale
with
categories LC_ALL
, LC_MONETARY
, or
LC_NUMERIC
.