Sets the locale-dependent conventions of an object.
Standard C Library (libc.a)
#include <locale.h>
struct lconv *localeconv ( )
The localeconv subroutine sets the components of an object using the lconv structure. The lconv structure contains values appropriate for the formatting of numeric quantities (monetary and otherwise) according to the rules of the current locale.
The fields of the structure with the type char * are strings, any of which (except decimal_point) can point to a null string, which indicates that the value is not available in the current locale or is of zero length. The fields with type char are nonnegative numbers, any of which can be the CHAR_MAX value which indicates that the value is not available in the current locale. The fields of the Iconv structure include the following:
Item | Description |
---|---|
char *decimal_point | The decimal-point character used to format non-monetary quantities. |
char *thousands_sep | The character used to separate groups of digits to the left of the decimal point in formatted non-monetary quantities. |
char *grouping | A string whose elements indicate the size of each group of
digits in formatted non-monetary quantities. The value of the grouping field is interpreted according to the following:
|
char *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 in accordance with those specified in ISO 4217, "Codes for the Representation of Currency and Funds." |
char *currency_symbol | The local currency symbol applicable to the current locale. |
char *mon_decimal_point | The decimal point used to format monetary quantities. |
char *mon_thousands_sep | The separator for groups of digits to the left of the decimal point in formatted monetary quantities. |
char *mon_grouping | A string whose elements indicate the size of each group of
digits in formatted monetary quantities. The value of the mon_grouping field is interpreted according to the following:
|
char *positive_sign | The string used to indicate a nonnegative formatted monetary quantity. |
char *negative_sign | The string used to indicate a negative formatted monetary quantity. |
char int_frac_digits | The number of fractional digits (those to the right of the decimal point) to be displayed in a formatted monetary quantity. |
char p_cs_precedes | Set to 1 if the specified currency symbol (the currency_symbol or int_curr_symbol field) precedes the value for a nonnegative formatted monetary quantity and set to 0 if the specified currency symbol follows the value for a nonnegative formatted monetary quantity. |
char p_sep_by_space | Set to 1 if the currency_symbol or int_curr_symbol field is separated by a space from the value for a nonnegative formatted monetary quantity and set to 0 if the currency_symbol or int_curr_symbol field is not separated by a space from the value for a nonnegative formatted monetary quantity. |
char n_cs_precedes | Set to 1 if the currency_symbol or int_curr_symbol field precedes the value for a negative formatted monetary quantity and set to 0 if the currency_symbol or int_curr_symbol field follows the value for a negative formatted monetary quantity. |
char n_sep_by_space | Set to 1 if the currency_symbol or int_curr_symbol field is separated by a space from the value for a negative formatted monetary quantity and set to 0 if the currency_symbol or int_curr_symbol field is not separated by a space from the value for a negative formatted monetary quantity. Set to 2 if the symbol and the sign string are adjacent and separated by a blank character. |
char p_sign_posn | Set to a value indicating the positioning of the positive sign (the positive_sign fields) for nonnegative formatted monetary quantity. |
char n_sign_posn | Set to a value indicating the positioning of the negative
sign (the negative_sign fields) for a negative formatted
monetary quantity. The values of the p_sign_posn and n_sign_posn fields are interpreted according to the following definitions:
|
The following table illustrates the rules that can be used by three countries to format monetary quantities:
Country | Formats |
---|---|
Italy |
|
Norway |
|
Switzerland |
|
The following table shows the values of the monetary members of the structure returned by the localeconv subroutine for these countries:
struct localeconv | Countries |
---|---|
char *in_curr_symbol |
|
char *currency_symbol |
|
char *mon_decimal_point |
|
char *mon_thousands_sep |
|
char *mon_grouping |
|
char *positive_sign |
|
char *negative_sign |
|
char int_frac_digits |
|
char frac_digits |
|
char p_cs_precedes |
|
char p_sep_by_space |
|
char n_cs_precedes |
|
char n_sep_by_space |
|
char p_sign_posn |
|
char n_sign_posn |
|
A pointer to the filled-in object is returned. In addition, calls to the setlocale subroutine with the LC_ALL, LC_MONETARY or LC_NUMERIC categories may cause subsequent calls to the localeconv subroutine to return different values based on the selection of the locale.