std:: lconv
|
定义于头文件
<clocale>
|
||
|
struct
lconv
;
|
||
类
std::lconv
包含由 C 区域设置定义的数值和货币格式化规则。可通过
std::localeconv
获取此结构体的对象。
std::lconv
的成员包含类型为
char
和
char
*
的值。除
decimal_point
外,每个
char
*
成员可能指向空字符(即空 C 字符串)。类型为
char
的成员均为非负数,若当前 C 区域设置中无对应值,则可能为
CHAR_MAX
。
目录 |
成员对象
非货币数值格式化参数
|
char*
decimal_point
|
用作小数点分隔符的字符
(公开成员对象) |
|
char*
thousands_sep
|
用于分隔小数点前数字组的字符
(公开成员对象) |
|
char*
grouping
|
用于指示数字组分组长度的字符串
(公开成员对象) |
货币数值格式化参数
|
char*
mon_decimal_point
|
用作小数点分隔符的字符
(公开成员对象) |
|
char*
mon_thousands_sep
|
用于分隔小数点前数字组的字符
(公开成员对象) |
|
char*
mon_grouping
|
指示数字组大小的字符串
(公开成员对象) |
|
char*
positive_sign
|
用于表示非负货币值的字符串
(公开成员对象) |
|
char*
negative_sign
|
用于表示负货币值的字符串
(公开成员对象) |
本地货币数值格式化参数
|
char*
currency_symbol
|
当前C区域设置中使用的货币符号
(公开成员对象) |
|
char
frac_digits
|
货币数值中小数点后要显示的位数
(公开成员对象) |
|
char
p_cs_precedes
|
1
表示货币符号位于非负值之前,
0
表示位于之后
(公开成员对象) |
|
char
n_cs_precedes
|
1
表示货币符号位于负值之前,
0
表示位于之后
(公开成员对象) |
|
char
p_sep_by_space
|
指示
currency_symbol
、
positive_sign
与非负货币数值之间的分隔方式
(公开成员对象) |
|
char
n_sep_by_space
|
指示
currency_symbol
、
negative_sign
与负货币数值之间的分隔方式
(公开成员对象) |
|
char
p_sign_posn
|
指示非负货币数值中
positive_sign
的位置
(公开成员对象) |
|
char
n_sign_posn
|
指示负货币数值中
negative_sign
的位置
(公开成员对象) |
国际货币数值格式化参数
|
char*
int_curr_symbol
|
当前C区域设置中用作国际货币名称的字符串
(公开成员对象) |
|
char
int_frac_digits
|
国际货币金额中小数点后要显示的位数
(公开成员对象) |
|
char
int_p_cs_precedes
(C++11)
|
1
表示 int_curr_symbol 位于非负国际货币值之前,
0
表示位于之后
(公开成员对象) |
|
char
int_n_cs_precedes
(C++11)
|
1
表示 int_curr_symbol 位于负国际货币值之前,
0
表示位于之后
(公开成员对象) |
|
char
int_p_sep_by_space
(C++11)
|
指示
int_curr_symbol
、
positive_sign
与非负国际货币值之间的分隔方式
(公开成员对象) |
|
char
int_n_sep_by_space
(C++11)
|
指示
int_curr_symbol
、
negative_sign
与负国际货币值之间的分隔方式
(公开成员对象) |
|
char
int_p_sign_posn
(C++11)
|
指示非负国际货币值中
positive_sign
的位置
(公开成员对象) |
|
char
int_n_sign_posn
(C++11)
|
指示负国际货币值中
negative_sign
的位置
(公开成员对象) |
由
grouping
和
mon_grouping
所指向的 C 字符串中的字符将根据其数值进行解释。当遇到终止符
'
\0
'
时,最后出现的数值将被视为对剩余数字的重复分组规则。若遇到
CHAR_MAX
,则后续数字不再进行分组。典型的三位数字分组规则对应
"
\003
"
。
p_sep_by_space
、
n_sep_by_space
、
int_p_sep_by_space
、
int_n_sep_by_space
的取值按以下方式解释:
| 0 | 货币符号与数值之间无空格 |
| 1 | 符号紧贴货币符号,数值通过空格分隔 |
| 2 | 符号紧贴数值,货币符号通过空格分隔 |
p_sign_posn
、
n_sign_posn
、
int_p_sign_posn
、
int_n_sign_posn
的取值按以下方式解释:
| 0 | 使用数值和货币符号周围的括号表示符号 |
| 1 | 符号位于数值和货币符号之前 |
| 2 | 符号位于数值和货币符号之后 |
| 3 | 符号位于货币符号之前 |
| 4 | 符号位于货币符号之后 |
示例
#include <clocale> #include <iostream> int main() { std::setlocale(LC_ALL, "ja_JP.UTF-8"); std::lconv* lc = std::localeconv(); std::cout << "Japanese currency symbol: " << lc->currency_symbol << '(' << lc->int_curr_symbol << ")\n"; }
输出:
Japanese currency symbol: ¥(JPY )
参阅
|
查询当前区域设置的数值和货币格式化详细信息
(函数) |
|
|
定义数值标点规则
(类模板) |
|
|
定义由
std::money_get
和
std::money_put
使用的货币格式化参数
(类模板) |
|
|
C 文档
关于
lconv
|
|