std::moneyp..._curr_symbol(3)
πΈ NAME πΈ
std::moneypunct::curr_symbol,do_curr_symbol - std::moneypunct::curr_symbol,do_curr_symbol
Okay bestie, this is the std::moneyp..._curr_symbol(3) page from the C++ Standard Libary, and we are officially in our currency-locale era. πΈβ¨
β¨ Synopsis β¨
Defined in header <locale>
public: (1)
string_type curr_symbol() const;
protected: (2)
virtual string_type do_curr_symbol() const;
- Public member function, calls the member function
do_curr_symbolof the most derived class. - Returns the string used as the currency identifier by this locale. If
International(the second template parameter ofstd::moneypunct) isfalse, the identifier is usually a single (wide) character, such as"οΏ₯"or"$". IfInternationalistrue, the identifier is usually a four-character string holding the three-character ISO 4217 currency code followed by a space ("JPY "or"USD ").
π Return value π
The object of type string_type holding the currency symbol or code. That's it, that's the vibe. π
π§ Example π§
// Run this code
#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");
}
Output:
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
Not me getting emotional over currency symbols in five different locales. ππ
π Defect reports π
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
- DR:
LWG 666 - Applied to:
C++98 - Behavior as published: the length of the identifier string was required to be 4 if
Internationalistrue - Correct behavior: not required
π See also π
do_pos_formatprovides the formatting pattern for currency valuesdo_neg_format(virtual protected member function)[virtual]
This page came from http://cppreference.com, version/date 2024.06.10, and the manual page is std::moneyp..._curr_symbol(3). Byeee bestie, go format some currencies and slay responsibly! π
π«Άπ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms