名稱空間
變體
操作

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

來自 cppreference.com
 
 
 
 
 
定義於標頭檔案 <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 未要求

[編輯] 參閱

提供貨幣值的格式模式
(虛保護成員函式) [編輯]