命名空间
变体
操作

std::moneypunct<CharT,International>::curr_symbol, do_curr_symbol

来自 cppreference.cn
 
 
 
 
 
定义于头文件 <locale>
public:
string_type curr_symbol() const;
(1)
protected:
virtual string_type do_curr_symbol() const;
(2)
1) 公有成员函数,调用最派生类的成员函数 do_curr_symbol
2) 返回此语言环境用作货币标识符的字符串。如果 Internationalstd::moneypunct 的第二个模板参数)为 false,则标识符通常是单个(宽)字符,例如 "¥""$"。如果 Internationaltrue,则标识符通常是一个四字符字符串,其中包含三字符的 ISO 4217 货币代码,后跟一个空格("JPY ""USD ")。

目录

[编辑] 返回值

类型为 string_type 的对象,持有货币符号或代码。

[编辑] 示例

#include <iostream>
#include <locale>
 
void show_ccy(const char* locname)
{
    std::locale loc(locname);
    std::cout << locname << " currency symbol is "
              << std::use_facet<std::moneypunct<char, true>>(loc).curr_symbol()
              << "or " << std::use_facet<std::moneypunct<char>>(loc).curr_symbol()
              << " for short\n";
}
 
int main()
{
    show_ccy("en_US.utf8");
    show_ccy("ja_JP.utf8");
    show_ccy("sv_SE.utf8");
    show_ccy("ru_RU.utf8");
    show_ccy("vi_VN.utf8");
}

输出

en_US.utf8 currency symbol is USD or $ for short
ja_JP.utf8 currency symbol is JPY or ¥ for short
sv_SE.utf8 currency symbol is SEK or kr for short
ru_RU.utf8 currency symbol is RUB or руб for short
vi_VN.utf8 currency symbol is VND or ₫ for short

[编辑] 缺陷报告

下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。

缺陷报告 应用于 发布时的行为 正确的行为
LWG 666 C++98 如果 Internationaltrue,则标识符字符串的长度要求为 4 未要求

[编辑] 参阅

提供货币值的格式模式
(虚保护成员函数) [编辑]