English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C Language Reference Manual locale.h struct lconv The header file defines specific regional settings, such as date format and currency symbol. Next, we will introduce some macros, as well as an important structure
Library macros
Serial Number | Macros & Description |
---|---|
1 | LC_ALL Set all the following options. |
2 | LC_COLLATE Affects the strcoll and strxfrm functions. |
3 | LC_CTYPE Affects all character functions. |
4 | LC_MONETARY Affects the currency information provided by the localeconv function. |
5 | LC_NUMERIC Affects the decimal point formatting and information provided by the localeconv function. |
6 | LC_TIME Affects the strftime function. |
The following lists the functions defined in the header file locale.h:
Serial Number | Function & Description |
---|---|
1 | char *setlocale(int category, const char *locale) Set or read localized information. |
2 | struct lconv *localeconv(void) Set or read localized information. |
typedef struct { char *decimal_point; char *thousands_sep; char *grouping; char *int_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; }
The following is the description of each field:
Serial Number | Field & Description |
---|---|
1 | decimal_point The decimal point character used for non-monetary values. |
2 | thousands_sep The thousand separator used for non-monetary values. |
3 | grouping A string representing the size of each group of digits in non-monetary values. Each character represents an integer value, each integer specifies the number of digits in the current group. A value of 0 means that the previous value will be applied to the remaining grouping. |
4 | int_curr_symbol The string used for international currency symbols. The first three characters are specified by ISO 4217:1987 Specified, the fourth character is used to separate the currency symbol and the currency amount. |
5 | currency_symbol The local symbol used for currency. |
6 | mon_decimal_point The decimal point character used for currency values. |
7 | mon_thousands_sep The thousand separator used for currency values. |
8 | mon_grouping A string representing the size of each group of digits in the currency value. Each character represents an integer value, each integer specifies the number of digits in the current group. A value of 0 means that the previous value will be applied to the remaining grouping. |
9 | positive_sign The character used for positive currency values. |
10 | negative_sign The character used for negative currency values. |
11 | int_frac_digits The number of decimal places to display after the decimal point in international currency values. |
12 | frac_digits The number of decimal places to display after the decimal point in the currency value. |
13 | p_cs_precedes If it is equal to 1then currency_symbol appears before the positive currency value. If it is equal to 0, then currency_symbol appears after the positive currency value. |
14 | p_sep_by_space If it is equal to 1then currency_symbol and positive currency values are separated by a space. If it is equal to 0, then currency_symbol and positive currency values are not separated by a space. |
15 | n_cs_precedes If it is equal to 1then currency_symbol appears before the negative currency value. If it is equal to 0, then currency_symbol appears after the negative currency value. |
16 | n_sep_by_space If it is equal to 1If it is equal to, then currency_symbol and negative currency values are separated by a space. If it is equal to 0, then currency_symbol and negative currency values are not separated by a space. |
17 | p_sign_posn to indicate the position of the positive sign in positive currency values. |
18 | n_sign_posn to indicate the position of the negative sign in negative currency values. |
The following values are used for p_sign_posn and n_sign_posn:
Value | Description |
---|---|
0 | Enclose the value and currency_symbol in parentheses. |
1 | The symbol placed before the value and currency_symbol. |
2 | The symbol placed after the value and currency_symbol. |
3 | The symbol placed immediately before the value and currency_symbol. |
4 | The symbol placed immediately after the value and currency_symbol. |