std::moneypunct<CharT,International>::curr_symbol, do_curr_symbol
來自 cppreference.com
< 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) 返回此語言環境用作貨幣識別符號的字串。如果
International
(std::moneypunct
的第二個模板引數)為 false,則識別符號通常是單個(寬)字元,例如 "¥" 或 "$"。如果 International
為 true,則識別符號通常是一個四字元字串,其中包含三字元的 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 | 如果 International 為 true,則識別符號字串的長度要求為 4。 |
未要求 |
[編輯] 參閱
[virtual] |
提供貨幣值的格式模式 (虛保護成員函式) |