Reputation: 89
I need to know how to use the ICU4C version 52 C API to display the locale Currency Symbol and code. i.e. ($ - USD)
Upvotes: 2
Views: 638
Reputation: 4350
Or, more directly, use ucurr_getName()
with the UCURR_SYMBOL_NAME
selector. You can also use ucurr_forLocale()
or ucurr_forLocaleAndDate()
to get the currency code without needing a formatter. Note that there can be multiple currencies for a locale.
Upvotes: 1
Reputation: 18228
There is probably more than one way how to do this. Here is one, that I think should work (untested):
Get the number format and format the value using it:
UErrorCode success = U_ZERO_ERROR;
UNumberFormat *nf;
const char* myLocale = "fr_FR";
// get locale specific number format
nf = unum_open( UNUM_CURRENCY, myLocale, success );
// use it to format the value
UChar buf[100];
unum_formatDouble (nf, 10.0, buf, 100, NULL, &success);
// close the format handle
unum_close(nf);
Upvotes: 1