在线文档教程
C++
本土化 | Localizations

std::lconv

STD::Iconv

Defined in header
struct lconv;

全班std::lconv包含C语言环境定义的数字和货币格式规则。此结构的对象可以用std::localeconv...成员std::lconv是类型的值char和类型char*.每个char*成员除外decimal_point可能指向空字符%28,即空C-字符串%29。类型成员char都是非负数,其中任何一个都可能是CHAR_MAX如果对应的值在当前C语言环境中不可用。

成员对象

非货币数字格式参数

char* decimal_pointthe character used as the decimal point (public member object)
char* thousands_septhe character used to separate groups of digits before the decimal point (public member object)
char* groupinga string whose elements indicate the sizes of digit groups (public member object)

货币数字格式参数

char* mon_decimal_pointthe character used as the decimal point (public member object)
char* mon_thousands_septhe character used to separate groups of digits before the decimal point (public member object)
char* mon_groupinga string whose elements indicate the sizes of digit groups (public member object)
char* positive_signa string used to indicate non-negative monetary quantity (public member object)
char* negative_signa string used to indicate negative monetary quantity (public member object)

本地货币数字格式参数

char* currency_symbolthe symbol used for currency in the current C locale (public member object)
char frac_digitsthe number of digits after the decimal point to display in a monetary quantity (public member object)
char p_cs_precedes1 if currency_symbol is placed before non-negative value, ​0​ if after (public member object)
char n_cs_precedes1 if currency_symbol is placed before negative value, ​0​ if after (public member object)
char p_sep_by_spaceindicates the separation of currency_symbol, positive_sign, and the non-negative monetary value (public member object)
char n_sep_by_spaceindicates the separation of currency_symbol, negative_sign, and the negative monetary value (public member object)
char p_sign_posnindicates the position of positive_sign in a non-negative monetary value (public member object)
char n_sign_posnindicates the position of negative_sign in a negative monetary value (public member object)

国际货币数字格式参数

char* int_curr_symbolthe string used as international currency name in the current C locale (public member object)
char int_frac_digitsthe number of digits after the decimal point to display in an international monetary quantity (public member object)
char int_p_cs_precedes (C++11)1 if currency_symbol is placed before non-negative international monetary value, ​0​ if after (public member object)
char int_n_cs_precedes (C++11)1 if currency_symbol is placed before negative international monetary value, ​0​ if after (public member object)
char int_p_sep_by_space (C++11)indicates the separation of currency_symbol, positive_sign, and the non-negative international monetary value (public member object)
char int_n_sep_by_space (C++11)indicates the separation of currency_symbol, negative_sign, and the negative international monetary value (public member object)
char int_p_sign_posn (C++11)indicates the position of positive_sign in a non-negative international monetary value (public member object)
char int_n_sign_posn (C++11)indicates the position of negative_sign in a negative international monetary value (public member object)

所指向的C-字符串的字符。groupingmon_grouping根据它们的数值进行解释。当终止'\0'遇到时,最后看到的值将被假定为对剩余的数字重复。如果CHAR_MAX遇到,则不会对其他数字进行分组。一次三位数的典型分组是"\003"...

的价值p_sep_by_space,,,n_sep_by_space,,,int_p_sep_by_space,,,int_n_sep_by_space解释如下:

0no space separates the currency symbol and the value
1sign sticks to the currency symbol, value is separated by a space
2sign sticks to the value. Currency symbol is separated by a space

的价值p_sign_posn,,,n_sign_posn,,,int_p_sign_posn,,,int_n_sign_posn解释如下:

0parentheses around the value and the currency symbol are used to represent the sign
1sign before the value and the currency symbol
2sign after the value and the currency symbol
3sign before the currency symbol
4sign after the currency symbol

二次

#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 )

二次

另见

localeconvqueries numeric and monetary formatting details of the current locale (function)
numpunctdefines numeric punctuation rules (class template)
moneypunctdefines monetary formatting parameters used by std::money_get and std::money_put (class template)

c国际康复会的文件

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/locale/lconv