The header file in the following listing defines a struct containing all the locale specific values.
struct lconv { /* "C" locale (default) */ char *decimal_point; /* "." */ /* Decimal point character to use for non-monetary numbers */ char *thousands_sep; /* "" */ /* Character to use to separate digit groups in the integral part of a non-monetary number. */ char *grouping; /* "\CHAR_MAX" */ /* Number of digits that form a group. CHAR_MAX means "no grouping", '\0' means take previous value. For example, the string "\3\0" specifies the repeated use of groups of three digits. */ char *int_curr_symbol; /* "" */ /* 4-character string for the international currency symbol according to ISO 4217. The last character is the separator between currency symbol and amount. */ char *currency_symbol; /* "" */ /* National currency symbol. */ char *mon_decimal_point; /* "." */ char *mon_thousands_sep; /* "" */ char *mon_grouping; /* "\CHAR_MAX" */ /* Same as decimal_point etc., but for monetary numbers. */ char *positive_sign; /* "" */ /* String to use for positive monetary numbers.*/ char *negative_sign; /* "" */ /* String to use for negative monetary numbers. */ char int_frac_digits; /* CHAR_MAX */ /* Number of fractional digits to print in a monetary number according to international format. */ har frac_digits; /* CHAR_MAX */ /* The same for national format. */ char p_cs_precedes; /* 1 */ /* 1 indicates that the currency symbol is left of a positive monetary amount; 0 indicates it is on the right. */ char p_sep_by_space; /* 1 */ /* 1 indicates that the currency symbol is separated from the number by a space for positive monetary amounts. */ char n_cs_precedes; /* 1 */ char n_sep_by_space; /* 1 */ /* The same for negative monetary amounts. */ char p_sign_posn; /* 4 */ char n_sign_posn; /* 4 */ /* Defines the position of the sign for positive and negative monetary numbers: 0 amount and currency are in parentheses 1 sign comes before amount and currency 2 sign comes after the amount 3 sign comes immediately before the currency 4 sign comes immediately after the currency */ };
There also are several constants that can be used in setlocale() to define which part of the locale to set. Refer to the following table:
| Constant | Description |
|---|---|
| LC_ALL | Changes the complete locale |
| LC_COLLATE | Only changes the locale for the strcoll() and strxfrm() functions |
| LC_MONETARY | Changes the locale for formatting monetary numbers |
| LC_NUMERIC | Changes the locale for numeric, i.e., non-monetary formatting |
| LC_TIME | Changes the locale for the strftime() function |
| LC_TYPE | Changes the locale for character handling and multi-byte character functions |
This implementation only supports the minimum C locale.