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

< cpp‎ | locale‎ | moneypunct
 
 
 
 
定义于头文件 <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

参阅

提供通货值的格式化模式
(虚受保护成员函数)