名前空間
変種
操作

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

From 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) このロケールによって通貨識別子として使用される文字列を返します。Internationalstd::moneypunctの2番目のテンプレートパラメータ)がfalseの場合、識別子は通常、"¥""$"のような1つの(ワイド)文字です。Internationaltrueの場合、識別子は通常、3文字のISO 4217通貨コードとその後にスペースが続く4文字の文字列("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++標準に遡って適用されました。

DR 適用対象 公開された動作 正しい動作
LWG 666 C++98 識別子文字列の長さは、Internationaltrueの場合、4であることが要求されていました。 要求されない

[編集] 関連項目

通貨値の書式設定パターンを提供します。
(virtual protected member function) [編集]
English 日本語 中文(简体) 中文(繁體)