LOCALECONV(3)

NAME
localeconv - get numeric and monetary formatting conventions

SYNOPSIS

#include <limits.h>
#include <locale.h>

struct lconv *localeconv()

DESCRIPTION

localeconv() returns a pointer to a structure of type struct lconv containing values appropriate for the formatting of numeric quantities (monetary and otherwise) according to the rules of the current locale.

The members of the structure with type (char *) are strings; if a string has the value "", the value is not available in the current locale or has zero length. The members with type char are nonnegative numbers; if any of them have the value CHAR_MAX the value is not available in the current locale. The lconv structure is defined in <locale.h> as follows:

    struct lconv {
        char	*decimal_point;		/* decimal point character */
        char	*thousands_sep;		/* thousands separator character */
        char	*grouping;		/* grouping of digits */
        char	*int_curr_symbol;	/* international currency symbol */
        char	*currency_symbol;	/* local currency symbol */
        char	*mon_decimal_point;	/* monetary decimal point character */
        char	*mon_thousands_sep;	/* monetary thousands separator */
        char	*mon_grouping;		/* monetary grouping of digits */
        char	*positive_sign;		/* monetary credit symbol */
        char	*negative_sign;		/* monetary debit symbol */
        char	int_frac_digits;		/* intl monetary number of fractional digits */
        char	frac_digits;		/* monetary number of fractional digits */
        char	p_cs_precedes;		/* true if currency symbol precedes credit */
        char	p_sep_by_space;		/* true if space separates c.s.  from credit */
        char	n_cs_precedes;		/* true if currency symbol precedes debit */
        char	n_sep_by_space;		/* true if space separates c.s.  from debit */
        char	p_sign_posn;		/* position of sign for credit */
        char	n_sign_posn;		/* position of sign for debit */
    };

The fields of this structure represent:

decimal_point
    The decimal-point character used to format non-monetary quantities.

thousands_sep
    The character used to separate groups of digits to the left of the decimal-point character in formatted non-monetary quantities.

grouping
    A string whose elements indicate the size of each group of digits in formatted non-monetary quantities.

int_curr_symbol
    The international currency symbol applicable to the current locale, left-justified within a four-character SPACE-padded field. The character sequences are those specified in: ISO 4217 Codes for the Representation of Currency and Funds.

currency_symbol
    The local currency symbol applicable to the current locale.

mon_decimal_point
    The decimal-point used to format monetary quantities.

mon_thousands_sep
    The character used to separate groups of digits to the left of the decimal-point character in formatted monetary quantities.

mon_grouping
    A string whose elements indicate the size of each group of digits in formatted monetary quantities.

positive_sign
    The string used to indicate a nonnegative-valued formatted monetary quantity.

negative_sign
    The string used to indicate a negative-valued formatted monetary quantity.

int_frac_digits
    The number of fractional digits (those after the decimal-point) to be displayed in an internationally formatted monetary quantity.

frac_digits
    The number of fractional digits (those to the right of the decimal-point) to be displayed in a formatted monetary quantity.

p_cs_precedes
    1 if the currency_symbol precedes the value for a nonnegative formatted monetary quantity; 0 if the currency_symbol succeeds the value for a nonnegative formatted monetary quantity.

p_sep_by_space
    1 if the currency_symbol is separated by a SPACE from the value for a nonnegative formatted monetary quantity; 0 if the currency_symbol is not separated by a SPACE from the value for a nonnegative formatted monetary quantity.

n_cs_precedes
    1 if the currency_symbol precedes the value for a negative formatted monetary quantity; 0 if the currency_symbol succeeds the value for a negative formatted monetary quantity.

n_sep_by_space
    1 if the currency_symbol is separated by a SPACE from the value for a negative formatted monetary quantity; 0 if the currency_symbol is not separated by a SPACE from the value for a negative formatted monetary quantity.

p_sign_posn
    A value indicating the positioning of the positive_sign for a nonnegative formatted monetary quantity.

n_sign_posn
    A value indicating the positioning of the negative_sign for a negative formatted monetary quantity.

The elements of grouping and mon_grouping are interpreted as follows:

    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 group. The next element is examined to determine the size of the next group of digits to the left of the current group.

The values of p_sign_posn and n_sign_posn are interpreted as follows:

    0   Parentheses surround the quantity and currency_symbol.

    1   The sign string precedes the quantity and currency_symbol.

    2   The sign string succeeds the quantity and currency_symbol.

    3   The sign string immediately precedes the currency_symbol.

    4   The sign string immediately succeds the currency_symbol.

The values for the members in the C locale are:

    field | value
    decimal_point | "."
    thousands_sep | ""
    grouping | ""
    int_curr_symbol | ""
    currency_symbol | ""
    mon_decimal_point | ""
    mon_thousands_sep | ""
    mon_grouping | ""
    positive_sign | ""
    negative_sign | ""
    int_frac_digits | CHAR_MAX
    frac_digits | CHAR_MAX
    p_cs_precedes | CHAR_MAX
    p_sep_by_space | CHAR_MAX
    n_cs_precedes | CHAR_MAX
    n_sep_by_space | CHAR_MAX
    p_sign_posn | CHAR_MAX
    n_sign_posn | CHAR_MAX

RETURN VALUES

localeconv() returns a pointer to struct lconv (see NOTES).

FILES
/usr/share/lib/locale/LC_MONETARY
    standard locale information directory for category LC_MONETARY
/usr/share/lib/locale/LC_NUMERIC
    standard locale information directory for category LC_NUMERIC

SEE ALSO
printf(3V), scanf(3V), setlocale(3V)

NOTES
localeconv() does not modify the struct lconv to which it returns a pointer, but subsequent calls to setlocale(3V) with categories LC_ALL, LC_MONETARY, or LC_NUMERIC may overwrite the contents of the structure.