Namespaces
Variants

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

From cppreference.net
定義先ヘッダ <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 の第2テンプレートパラメータ)が false の場合、識別子は通常「¥」や「$」のような単一の(ワイド)文字である。 International true の場合、識別子は通常、3文字の ISO 4217 通貨コードとそれに続くスペース(「JPY 」や「USD 」)を含む4文字の文字列である。

目次

戻り値

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 International true の場合、識別子文字列の長さは 4 であることが要求されていた 要求されない

関連項目

通貨値のフォーマットパターンを提供する
(仮想保護メンバー関数)