#include <locale.h>
struct lconv *localeconv(void);
The localeconv() function shall set the components of an object with the type struct lconv with the 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 pointers to strings, any of which (except decimal_point) 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 non-negative numbers, any of which can be {CHAR_MAX} to indicate that the value is not available in the current locale.
The members include the following:
The radix character used to format non-monetary quantities.
The character used to separate groups of digits before the decimal-point character in formatted non-monetary quantities.
A string whose elements taken as one-byte integer values indicate the size of each group of digits in formatted non-monetary quantities.
The international currency symbol applicable to the current locale. The first three characters contain the alphabetic international currency symbol in accordance with those specified in the ISO 4217:1995 standard. The fourth character (immediately preceding the null byte) is the character used to separate the international currency symbol from the monetary quantity.
The local currency symbol applicable to the current locale.
The radix character used to format monetary quantities.
The separator for groups of digits before the decimal-point in formatted monetary quantities.
A string whose elements taken as one-byte integer values indicate the size of each group of digits in formatted monetary quantities.
The string used to indicate a non-negative valued formatted monetary quantity.
The string used to indicate a negative valued formatted monetary quantity.
The number of fractional digits (those after the decimal-point) to be displayed in an internationally formatted monetary quantity.
The number of fractional digits (those after the decimal-point) to be displayed in a formatted monetary quantity.
Set to 1 if the currency_symbol precedes the value for a non-negative formatted monetary quantity. Set to 0 if the symbol succeeds the value.
Set to a value indicating the separation of the currency_symbol, the sign string, and the value for a non-negative formatted monetary quantity.
Set to 1 if the currency_symbol precedes the value for a negative formatted monetary quantity. Set to 0 if the symbol succeeds the value.
Set to a value indicating the separation of the currency_symbol, the sign string, and the value for a negative formatted monetary quantity.
Set to a value indicating the positioning of the positive_sign for a non-negative formatted monetary quantity.
Set to a value indicating the positioning of the negative_sign for a negative formatted monetary quantity.
Set to 1 or 0 if the int_curr_symbol respectively precedes or succeeds the value for a non-negative internationally formatted monetary quantity.
Set to 1 or 0 if the int_curr_symbol respectively precedes or succeeds the value for a negative internationally formatted monetary quantity.
Set to a value indicating the separation of the int_curr_symbol, the sign string, and the value for a non-negative internationally formatted monetary quantity.
Set to a value indicating the separation of the int_curr_symbol, the sign string, and the value for a negative internationally formatted monetary quantity.
Set to a value indicating the positioning of the positive_sign for a non-negative internationally formatted monetary quantity.
Set to a value indicating the positioning of the negative_sign for a negative internationally formatted monetary quantity.
The elements of grouping and mon_grouping are interpreted according to the following:
The values of p_sep_by_space, n_sep_by_space, int_p_sep_by_space, and int_n_sep_by_space are interpreted according to the following:
For int_p_sep_by_space and int_n_sep_by_space, the fourth character of int_curr_symbol is used instead of a space.
The values of p_sign_posn, n_sign_posn, int_p_sign_posn, and int_n_sign_posn are interpreted according to the following:
The implementation shall behave as if no function in this volume of IEEE Std 1003.1-2001 calls localeconv().
The localeconv() function need not be reentrant. A function that is not required to be reentrant is not required to be thread-safe.
The localeconv() function shall return a pointer to the filled-in object. The application shall not modify the structure pointed to by the return value which may be overwritten by a subsequent call to localeconv(). In addition, calls to setlocale() with the categories LC_ALL , LC_MONETARY , or LC_NUMERIC may overwrite the contents of the structure.
No errors are defined.
The following sections are informative.
The following table illustrates the rules which may be used by four countries to format monetary quantities.
Country | Positive Format | Negative Format | International Format | |||
Italy | L.1.230 | -L.1.230 | ITL.1.230 | |||
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:
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 | |||
p_sign_posn | 1 | 1 | 1 | 1 | |||
n_sign_posn | 1 | 4 | 2 | 2 | |||
int_p_cs_precedes | 1 | 1 | 1 | 1 | |||
int_n_cs_precedes | 1 | 1 | 1 | 1 | |||
int_p_sep_by_space | 0 | 0 | 0 | 0 | |||
int_n_sep_by_space | 0 | 0 | 0 | 0 | |||
int_p_sign_posn | 1 | 1 | 1 | 1 | |||
int_n_sign_posn | 1 | 4 | 4 | 2 |
isalpha() , isascii() , nl_langinfo() , printf() , scanf() , setlocale() , strcat() , strchr() , strcmp() , strcoll() , strcpy() , strftime() , strlen() , strpbrk() , strspn() , strtok() , strxfrm() , strtod() , the Base Definitions volume of IEEE Std 1003.1-2001, <langinfo.h>, <locale.h>