locale(3c) DG/UX 4.30 locale(3c)
NAME
setlocale, localeconv - localization routines
SYNOPSIS
#include <locale.h>
char *setlocale(category, locale)
int category;
char *locale;
struct lconv *localeconv(void);
DESCRIPTION
The setlocale function is used to set or query some or all
categories of a program's current locale. A category may be
any one of the following:
LCALL the entire locale
LCCOLLATE affects behavior of strcoll and strxfrm (see
string(3c))
LCCTYPE affects character and multibyte operations
LCMONETARY affects monetary formatting information
LCNUMERIC affects decimal-point character and non-
monetary formatting information
LCTIME affects behavior of strftime (see ctime(3c))
A value of "C" for locale specifies the minimal environment
for C translation; this is the locale selected at program
startup. A value of "" specifies the implementation-defined
native environment. Other locales may be implementation-
defined.
When locale is non-null and the selection can be honored,
setlocale returns a pointer to the string associated with
the specified category for the selected locale. If the
selection cannot be honored, setlocale returns a NULL
pointer, and the locale is not changed.
When called with a NULL pointer for locale, setlocale
returns a pointer to the string associated with the
specified category for the program's current locale.
The string returned by setlocale may be used as the locale
argument in subsequent calls to restore the locale
associated with a specified category.
The localeconv function returns a pointer to a structure
Licensed material--property of copyright holder(s) Page 1
locale(3c) DG/UX 4.30 locale(3c)
that holds appropriate formatting information for the
current locale. The lconv structure, which is declared in
the header file <locale.h>, has the following members:
char *decimalpoint
The decimal-point character used to format non-monetary
quantities.
char *thousandssep
The character used to separate groups of digits before
the decimal point in non-monetary quantities.
char *grouping
A string whose elements indicate the size of each group
of digits in non-monetary quantities.
char *intcurrsymbol
International currency symbol. The first three
characters are those specified in ISO 4217 Codes for
the Representation of Currency and Funds; the fourth is
the character used to separate the currency symbol from
the monetary quantity.
char *currencysymbol
The local currency symbol.
char *mondecimalpoint
The decimal-point character used in formatting monetary
quantities.
char *monthousandssep
The character used to separate groups of digits before
the decimal-point in monetary quantities.
char *mongrouping
A string whose elements indicate the size of each group
of digits in monetary quantities.
char *positivesign
A string used to indicate a nonnegative-valued monetary
quantity.
char *negativesign
A string used to indicate a negative-valued monetary
quantity.
char intfracdigits
The number of fractional digits to be displayed in an
internationally formatted monetary quantity.
char fracdigits
The number of fractional digits to be displayed in a
Licensed material--property of copyright holder(s) Page 2
locale(3c) DG/UX 4.30 locale(3c)
formatted monetary quantity.
char pcsprecedes
Set to 1 or 0 if the currencysymbol precedes or
succeeds the value for a nonnegative monetary quantity.
char psepbyspace
Set to 1 or 0 if the currencysymbol is or is not
separated by a space from the value for a nonnegative
monetary quantity.
char ncsprecedes
Set to 1 or 0 if the currencysymbol precedes or
succeeds the space from the value for a negative
monetary quantity.
char nsepbyspace
Set to 1 or 0 if the currencysymbol is or is not
separated by a value for a negative monetary quantity.
char psignposn
Set to a value indicating the positioning of the
positivesign for a nonnegative monetary quantity.
char nsignpos
Set to a value indicating the positioning of the
negativesign for a negative monetary quantity.
The elements of grouping and mongrouping are interpreted as
follows:
CHARMAX No further grouping is to be performed.
0 The previous element is to be used repeatedly for
the remaining digits.
other The number of digits that comprise the current
group. The next element is examined to determine
the size of the next group of digits before the
current group.
The value of psignposn and nsignposn is interpreted as
follows:
0 Parentheses surround the quantity and currencysymbol.
1 The sign string precedes the quantity and
currencysymbol.
2 The sign string follows the quantity and
currencysymbol.
Licensed material--property of copyright holder(s) Page 3
locale(3c) DG/UX 4.30 locale(3c)
3 The sign string immediately precedes the
currencysymbol.
4 The sign string immediately follows the currencysymbol.
Any member of the lconv structure with type char * (except
decimalpoint) may point to "", indicating that the value is
not available in the current locale or is of zero length.
Any member with type char may have the value CHARMAX,
indicating that the value is not available in the current
locale. In the "C" locale, the decimalpoint is set to ".",
all other strings to "", and all char values to CHARMAX.
The structure returned by localeconv should not be modified
by the program, but calls to setlocale with categories
LCALL, LCMONETARY, or LCNUMERIC may overwrite the
contents of the structure.
EXAMPLE
The following table illustrates the rules that may be used
by four different countries to format monetary quantities:
Country Positive format Negative format International format
Italy L.1.234 -L.1.234 ITL.1.234
Netherlands F 1.234,56 F -1.234,56 NLG 1.234,56
Norway kr1.234,56 kr1.234,56- NOK 1.234,56
Switzerland SFrs.1,234.56 SFrs.1,234.56C CHF 1,234.56
For these four countries, the values for the monetary
members of the lconv structure are:
Italy Netherlands Norway Switzerland
int_curr_symbol "ITL." "NLG " "NOK " "CHF "
currency_symbol "L." "F" "kr" "SFrs."
mon_decimal_point "" "," "," "."
mon_thousands_sep "." "." "." ","
mon_grouping "\3" "\3" "\3" "\3"
positive_sign "" "" "" ""
negative_sign "-" "-" "-" "C"
int_frac_digits 0 2 2 2
frac_digits 0 2 2 2
p_cs_precedes 1 1 1 1
p_sep_by_space 0 1 0 0
n_cs_precedes 1 1 1 1
n_sep_by_space 0 1 0 0
Licensed material--property of copyright holder(s) Page 4
locale(3c) DG/UX 4.30 locale(3c)
p_sign_posn 1 1 1 1
n_sign_posn 1 4 2 2
SEE ALSO
string(3c), multibyte(3c), ctime (3c)
Licensed material--property of copyright holder(s) Page 5