localeconv -- Retrieve Numeric Formatting Convention

Format

#include <locale.h>
struct lconv *localeconv(void);

Language Level: ANSI, XPG4
localeconv retrieves information about the environment for the current locale and places the information in a structure of type struct lconv. Subsequent calls to localeconv, or to setlocale with the argument LC_ALL, LC_MONETARY, or LC_NUMERIC, can overwrite the structure.

The structure contains the members listed below. Defaults shown are for the "C" locale. Pointers to strings with a value of "" indicate that the value is not available in this locale or is of zero length. Character types with a value of UCHAR_MAX indicate that the value is not available in this locale.

Element Purpose of Element Default
char *decimal_point Decimal-point character for formatting nonmonetary quantities. "."
char *thousands_sep Character used to separate groups of digits to the left of the decimal-point character in formatted nonmonetary quantities. ""
char *grouping Size of each group of digits in formatted nonmonetary quantities. The value of each character in the string determines the number of digits in a group. CHAR_MAX indicates that there are no further groupings. 0 indicates that the previous element is to be used for the remainder of the digits. ""
char *int_curr_symbol International currency symbol. The first three characters contain the alphabetic international currency symbol. The fourth character (usually a space) separates the international currency symbol from the monetary quantity. ""
char *currency_symbol Local currency symbol. ""
char *mon_decimal_point Decimal-point character for formatting monetary quantities. "."
char *mon_thousands_sep Separator for digits in formatted monetary quantities. ""
char *mon_grouping Size of each group of digits in formatted monetary quantities. The value of each character in the string determines the number of digits in a group. CHAR_MAX indicates that there are no further groupings. 0 indicates that the previous element is to be used for the remainder of the digits. ""
char *positive_sign Positive sign used in monetary quantities. ""
char *negative_sign Negative sign used in monetary quantities. ""
char int_frac_digits Number of displayed digits to the right of the decimal place for internationally formatted monetary quantities. UCHAR_MAX
char frac_digits Number of digits to the right of the decimal place in monetary quantities. UCHAR_MAX
char p_cs_precedes 1 if the currency_symbol precedes the value for a nonnegative formatted monetary quantity; 0 if it does not. UCHAR_MAX
char p_sep_by_space 1 if the currency_symbol is separated by a space from the value of a nonnegative formatted monetary quantity; 0 if it is not. UCHAR_MAX
char n_cs_precedes 1 if the currency_symbol precedes the value for a negative formatted monetary quantity; 0 if it does not. UCHAR_MAX
char n_sep_by_space 1 if the currency_symbol is separated by a space from the value of a negative formatted monetary quantity; 0 if it is not. UCHAR_MAX
char p_sign_posn Position of the positive_sign for a nonnegative formatted monetary quantity. UCHAR_MAX
char n_sign_posn Position of the negative_sign for a negative formatted monetary quantity. UCHAR_MAX
char *left_parenthesis Symbol to appear to the left of a negative-valued monetary symbol (such as a loss or deficit). "("
char *right_parenthesis Symbol to appear to the right of a negative-valued monetary symbol (such as a loss or deficit). ")"
char *debit_sign String to indicate a non-negative-valued formatted monetary quantity. "DB"
char *credit_sign String to indicate a negative-valued formatted monetary quantity. "CR"

The grouping and mon_grouping members can have the following values:

Value Meaning
CHAR_MAX No further grouping is to be performed.
0 The previous element is to be repeatedly used for the rest of the 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 n_sign_posn and p_sign_posn elements can have the following values:

Value Meaning
0 The quantity and currency_symbol are enclosed in parentheses.
1 The sign precedes the quantity and currency_symbol.
2 The sign follows the quantity and currency_symbol.
3 The sign precedes the currency_symbol.
4 The sign follows the currency_symbol.
5 Use debit_sign for p_sign_posn or credit_sign for n_sign_posn.

Return Value
localeconv returns a pointer to the lconv structure.

Example



setlocale -- Set Locale
<locale.h>