English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Online Tools

O)

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C Language Flow Control

C Language Structure

C Language File

C Other

C Standard Library <locale.h>

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

And two important functions.

Library macros

Serial NumberMacros & Description
1LC_ALL
Set all the following options.
2LC_COLLATE
Affects the strcoll and strxfrm functions.
3LC_CTYPE
Affects all character functions.
4LC_MONETARY
Affects the currency information provided by the localeconv function.
5LC_NUMERIC
Affects the decimal point formatting and information provided by the localeconv function.
6LC_TIME
Affects the strftime function.

Library functions

The following lists the functions defined in the header file locale.h:

Serial NumberFunction & Description
1char *setlocale(int category, const char *locale)
Set or read localized information.
2struct lconv *localeconv(void)
Set or read localized information.

Library structure

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 NumberField & Description
1decimal_point
The decimal point character used for non-monetary values.
2thousands_sep
The thousand separator used for non-monetary values.
3grouping
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.
4int_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.
5currency_symbol
The local symbol used for currency.
6mon_decimal_point
The decimal point character used for currency values.
7mon_thousands_sep
The thousand separator used for currency values.
8mon_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.
9positive_sign
The character used for positive currency values.
10negative_sign
The character used for negative currency values.
11int_frac_digits
The number of decimal places to display after the decimal point in international currency values.
12frac_digits
The number of decimal places to display after the decimal point in the currency value.
13p_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.
14p_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.
15n_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.
16n_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.
17p_sign_posn
to indicate the position of the positive sign in positive currency values.
18n_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:

ValueDescription
0Enclose the value and currency_symbol in parentheses.
1The symbol placed before the value and currency_symbol.
2The symbol placed after the value and currency_symbol.
3The symbol placed immediately before the value and currency_symbol.
4The symbol placed immediately after the value and currency_symbol.