C++官网参考链接:https://cplusplus.com/reference/clocale/lconv/
类型
struct lconv
struct lconv;
数值的格式化信息
该结构保存关于如何书写数值(货币值和非货币值)的格式化信息。
函数localeconv返回这种类型的对象。
它包含以下成员(不一定以下面表中的顺序):
成员常量
member | type | value in "C" locale | description |
---|---|---|---|
decimal_point | char* | "." | Decimal-point separator used for non-monetary quantities. (用于非货币量的小数点分隔符。) |
thousands_sep | char* | "" | Separators used to delimit groups of digits to the left of the decimal point for non-monetary quantities. (用于分隔非货币量小数点左侧的数字组的分隔符。) |
grouping | char* | "" | Specifies the amount of digits that form each of the groups to be separated by thousands_sep separator for non-monetary quantities. This is a zero-terminated sequence of (对于非货币量,指定构成每个组的数字量,这些组将由thousands_sep分隔符分隔。这是一个以0终止的char值序列,从右开始的每个连续组可能包含不同的组大小,每个数字表示组的数字数量;此字符串中结束0之前的最后一个数字用于其余组。例如, 假设thousand_sep设为",",表示的数字是一百万(1000000): 如果分组设置为“\3”,则数字将表示为:1,000,000 如果分组设置为“\1\2\3”,则数字将表示为:1000,00,0 如果分组设置为“\3\1”,则数字将表示为:1,0,0,0,000 CHAR_MAX表示不再进行分组。) |
int_curr_symbol | char* | "" | International currency symbol. This is formed by the three-letter ISO-4217 entry code for the currency, like (国际货币符号。这是由三字母的ISO-4217输入代码组成的,就像“USD”代表美元,“GBP”代表英镑,后面跟着用来将该符号与货币量分隔开的字符) |
currency_symbol | char* | "" | Local currency symbol, like (本地货币符号,如“$”。) |
mon_decimal_point | char* | "" | Decimal-point separator used for monetary quantities. (用于货币量的小数点分隔符。) |
mon_thousands_sep | char* | "" | Separators used to delimit groups of digits to the left of the decimal point for monetary quantities. (对于货币量,该分隔符用于分隔小数点左侧的数字组。) |
mon_grouping | char* | "" | Specifies the amount of digits that form each of the groups to be separated by mon_thousands_sep separator for monetary quantities. See grouping description above. (指定组成每个组的数字数量,用mon_thousands_sep分隔符分隔货币量。参考上面的grouping说明。) |
positive_sign | char* | "" | Sign to be used for nonnegative (positive or zero) monetary quantities. (用于非负(正或零)货币量的符号。) |
negative_sign | char* | "" | Sign to be used for negative monetary quantities. (用于负货币量的符号。) |
frac_digits | char | CHAR_MAX | Amount of fractional digits to the right of the decimal point for monetary quantities in the local format. (本地格式的货币量的小数点右边的小数位数。) |
p_cs_precedes | char | CHAR_MAX | Whether the currency symbol should precede nonnegative (positive or zero) monetary quantities. If this value is (货币符号是否应位于非负(正或零)货币量之前。如果该值为1,则货币符号应该在前面;如果它是0,它应该在后面。) |
n_cs_precedes | char | CHAR_MAX | Whether the currency symbol should precede negative monetary quantities. If this value is (货币符号是否应位于负货币量之前。如果该值为1,则货币符号应该在前面;如果它是0,它应该在后面。) |
p_sep_by_space | char | CHAR_MAX | Whether a space should appear between the currency symbol and nonnegative (positive or zero) monetary quantities. If this value is (货币符号与非负(正或零)货币量之间是否应出现空白。如果该值为1,则应该出现空白;如果是0,就不应该出现空白。) |
n_sep_by_space | char | CHAR_MAX | Whether a space should appear between the currency symbol and negative monetary quantities. If this value is (货币符号与负货币量之间是否应出现空白。如果该值为1,则应该出现空白;如果是0,就不应该出现空白。) |
p_sign_posn | char | CHAR_MAX | Position of the sign for nonnegative (positive or zero) monetary quantities: (非负(正或零)货币量的符号位置: 0:货币符号和用圆括号括起来的货币量。 1:在货币量和货币符号前标记。 2:在货币量和货币符号后标记。 3:在货币符号前面标记。 4:在货币符号后面标记。 CHAR_MAX:未指定。) |
n_sign_posn | char | CHAR_MAX | Position of the sign for negative monetary quantities. See p_sign_posn above. (负货币量的符号位置。参考上面的p_sign_posn。) |
int_frac_digits | char | CHAR_MAX | Same as frac_digits, but for the international format (instead of the local format). (与frac_digits相同,但用于国际格式(而不是本地格式)。) |
int_p_cs_precedes | char | CHAR_MAX | Same as p_cs_precedes, but for the international format. (与p_cs_precedes相同,但用于国际格式。) |
int_n_cs_precedes | char | CHAR_MAX | Same as n_cs_precedes, but for the international format. (与n_cs_precedes相同,但用于国际格式。) |
int_p_sep_by_space | char | CHAR_MAX | Same as p_sep_by_space, but for the international format. (与p_sep_by_space相同,但用于国际格式。) |
int_n_sep_by_space | char | CHAR_MAX | Same as n_sep_by_space, but for the international format. (与n_sep_by_space相同,但用于国际格式。) |
int_p_sign_posn | char | CHAR_MAX | Same as p_sign_posn, but for the international format. (与p_sign_posn相同,但用于国际格式。) |
int_n_sign_posn | char | CHAR_MAX | Same as n_sign_posn, but for the international format. (与n_sign_posn相同,但用于国际格式。) |
对于char*类型的成员,值为"";或对于char类型的成员,值为CHAR_MAX表示该值在语言环境设置中不可用。
兼容性
以int_p和int_n(上面黄色部分)开头的成员是为符合1999年或更高版本C标准的库定义的(只有2011年以后的C++标准才要求:C++11)。