Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

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

      From cppreference.com
      <cpp‎ |locale‎ |moneypunct
       
       
       
      Localization library
       
       
      Defined in header<locale>
      public:
      string_type curr_symbol()const;
      (1)
      protected:
      virtual string_type do_curr_symbol()const;
      (2)
      1) Public member function, calls the member functiondo_curr_symbol of the most derived class.
      2) Returns the string used as the currency identifier by this locale. IfInternational (the second template parameter ofstd::moneypunct) isfalse, the identifier is usually a single (wide) character, such as"¥" or"$". IfInternational istrue, the identifier is usually a four-character string holding the three-characterISO 4217 currency code followed by a space ("JPY " or"USD ").

      Contents

      [edit]Return value

      The object of typestring_type holding the currency symbol or code.

      [edit]Example

      Run this code
      #include <iostream>#include <locale> void show_ccy(constchar* 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");}

      Output:

      en_US.utf8 currency symbol is USD or $ for shortja_JP.utf8 currency symbol is JPY or ¥ for shortsv_SE.utf8 currency symbol is SEK or kr for shortru_RU.utf8 currency symbol is RUB or руб for shortvi_VN.utf8 currency symbol is VND or ₫ for short

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 666C++98the length of the identifier string was required to be4 ifInternational istruenot required

      [edit]See also

      provides the formatting pattern for currency values
      (virtual protected member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/locale/moneypunct/curr_symbol&oldid=149565"

      [8]ページ先頭

      ©2009-2026 Movatter.jp