localeconv(3C) localeconv(3C)
NAME
localeconv - get numeric formatting information
SYNOPSIS
#include <locale.h>
struct lconv *localeconv(void);
DESCRIPTION
localeconv() sets the components of an object with type struct lconv
(defined in locale.h) with the values appropriate for the formatting
of numeric quantities (monetary and otherwise) according to the rules
of the current locale [see setlocale(3C)]. The definition of struct
lconv is given below (the values for the fields in the C locale are
given in comments):
char *decimalpoint; /* "." */
char *thousandssep; /* "" (zero length string) */
char *grouping; /* "" */
char *intcurrsymbol; /* "" */
char *currencysymbol; /* "" */
char *mondecimalpoint; /* "" */
char *monthousandssep; /* "" */
char *mongrouping; /* "" */
char *positivesign; /* "" */
char *negativesign; /* "" */
char intfracdigits; /* CHARMAX */
char fracdigits; /* CHARMAX */
char pcsprecedes; /* CHARMAX */
char psepbyspace; /* CHARMAX */
char ncsprecedes; /* CHARMAX */
char nsepbyspace; /* CHARMAX */
char psignposn; /* CHARMAX */
char nsignposn; /* CHARMAX */
The members of the structure with type char * are strings, any of
which (except decimalpoint) can point to "", to indicate that the
value is not available in the current locale or is of zero length. The
members with type char are nonnegative numbers, any of which can be
CHARMAX (defined in the limits.h header file) to indicate that the
value is not available in the current locale. The members are the fol-
lowing:
char *decimalpoint
The decimal-point character used to format non-monetary quanti-
ties.
char *thousandssep
The character used to separate groups of digits to the left of
the decimal-point character in formatted non-monetary quantities.
Page 1 Reliant UNIX 5.44 Printed 11/98
localeconv(3C) localeconv(3C)
char *grouping
A string in which each element is taken as an integer that indi-
cates the number of digits that comprise the current group in a
formatted non-monetary quantity. The elements of grouping are
interpreted according to the following:
CHAR-MAX No further grouping is to be performed.
0 The previous element is to be repeatedly used for the
remainder of the digits.
other The value is the number of digits that comprise the
current the next group of digits to the left of the
current group.
char *intcurrsymbol
The international currency symbol. The operand is a four-
character string. The first three characters contain the interna-
tional currency symbol in accordance with ISO 4217:1987. The
fourth character is the character used to separate the interna-
tional currency symbol from the monetary quantity.
char *currencysymbol
The local currency symbol applicable to the current locale.
char *mondecimalpoint
The decimal point used to format monetary quantities. In the
ISO-C standard, this component is limited to one byte. A multi-
byte operand will produce an undefined result.
char *monthousandssep
The separator for groups of digits to the left of the decimal
point in formatted monetary quantities. In the ISO-C standard,
this component is limited to one byte. A multibyte operand will
produce an undefined result.
char *mongrouping
Size of all groups of digits in formatted monetary quantities.
The operand is a series of integers separated by semicolons. Each
integer indicates the number of digits in each group. The first
number indicates the size of the group directly preceding the
decimal separator; the following numbers define the preceding
groups. If the last number is not -1, the preceding group (if
there is one) is always used for the remaining digits. If the
last number is -1, no further grouping is performed.
char *positivesign
The string used to indicate a non-negative-valued formatted mone-
tary quantity.
Page 2 Reliant UNIX 5.44 Printed 11/98
localeconv(3C) localeconv(3C)
char *negativesign
The string used to indicate a negative-valued formatted monetary
quantity.
char intfracdigits
The number of fractional digits to be displayed in an interna-
tionally formatted monetary quantity where intcurrsymbol is
used.
char fracdigits
The number of fractional digits to be displayed in a formatted
monetary quantity where currencysymbol is used.
char pcsprecedes
Set to 1 or 0 if the currencysymbol or intcurrsymbol respec-
tively precedes or succeeds the value for a nonnegative formatted
monetary quantity.
char psepbyspace
Set to 0 if no space separates the currencysymbol or
intcurrsymbol from the value for a nonnegative formatted mone-
tary quantity. Set to 1 if a space separates the symbol from the
value; and set to 2 if a space separates the symbol and the sign
string, if adjacent.
char ncsprecedes
If this component has the value 1, the currencysymbol or
intcurrsymbol precedes the value for a negative formatted mone-
tary quantity. Otherwise this component is set to 0.
char nsepbyspace
Set to 1 if the currencysymbol or intcurrsymbol is separated
by a space from the value for a nonnegative formatted monetary
quantity. Otherwise this component is set to 0.
char psignposn
Nonnegative formatted monetary quantity. The values of
psignposn and nsignposn are interpreted according to the fol-
lowing:
0 Parentheses surround the quantity and currencysymbol or
intcurrsymbol.
1 The sign string precedes the quantity and currencysymbol or
intcurrsymbol.
2 The sign string succeeds the quantity and currencysymbol or
intcurrsymbol.
3 The sign string immediately precedes the currencysymbol or
intcurrsymbol.
Page 3 Reliant UNIX 5.44 Printed 11/98
localeconv(3C) localeconv(3C)
4 The sign string immediately succeeds the currencysymbol or
intcurrsymbol.
char nsignposn
Set to a value indicating the positioning of the negativesign
for a negative formatted monetary quantity.
RESULT
localeconv() returns a pointer to the filled-in object. The structure
pointed to by the return value may be overwritten by a subsequent call
to localeconv().
EXAMPLES
The following table illustrates the rules used by four 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 respective values for the monetary
members of the structure returned by localeconv() are as follows:
Italy Netherlands Norway Switzerland
intcurrsymbol "ITL." "NLG " "NOK " "CHF "
currencysymbol "L." "F" "kr" "SFrs."
mondecimalpoint "" "," "," "."
monthousandssep "." "." "." ","
mongrouping "\3" "\3" "\3" "\3"
positivesign "" "" "" ""
negativesign "-" "-" "-" "C"
intfracdigits 0 2 2 2
fracdigits 0 2 2 2
pcsprecedes 1 1 1 1
psepbyspace 0 1 0 0
ncsprecedes 1 1 1 1
nsepbyspace 0 1 0 0
psignposn 1 1 1 1
nsignposn 1 4 2 2
FILES
/usr/lib/locale/locale/LCMONETARY
LCMONETARY database for locale
/usr/lib/locale/locale/LCNUMERIC
LCNUMERIC database for locale
Page 4 Reliant UNIX 5.44 Printed 11/98
localeconv(3C) localeconv(3C)
SEE ALSO
chrtbl(1M), montbl(1M), setlocale(3C).
Page 5 Reliant UNIX 5.44 Printed 11/98