ICU 76.1 76.1
|
C API: Encapsulates information about a currency. More...
Go to the source code of this file.
Typedefs | |
typedef enum UCurrencyUsage | UCurrencyUsage |
Currency Usage used for Decimal Format. | |
typedef enum UCurrNameStyle | UCurrNameStyle |
Selector constants for ucurr_getName(). | |
typedef const void * | UCurrRegistryKey |
typedef enum UCurrCurrencyType | UCurrCurrencyType |
Selector constants for ucurr_openCurrencies(). | |
Enumerations | |
enum | UCurrencyUsage { UCURR_USAGE_STANDARD =0 , UCURR_USAGE_CASH =1 , UCURR_USAGE_COUNT =2 } |
Currency Usage used for Decimal Format. More... | |
enum | UCurrNameStyle { UCURR_SYMBOL_NAME , UCURR_LONG_NAME , UCURR_NARROW_SYMBOL_NAME , UCURR_FORMAL_SYMBOL_NAME , UCURR_VARIANT_SYMBOL_NAME } |
Selector constants for ucurr_getName(). More... | |
enum | UCurrCurrencyType { UCURR_ALL = INT32_MAX , UCURR_COMMON = 1 , UCURR_UNCOMMON = 2 , UCURR_DEPRECATED = 4 , UCURR_NON_DEPRECATED = 8 } |
Selector constants for ucurr_openCurrencies(). More... | |
Functions | |
U_CAPI int32_t | ucurr_forLocale (const char *locale, UChar *buff, int32_t buffCapacity, UErrorCode *ec) |
Finds a currency code for the given locale. | |
U_CAPI UCurrRegistryKey | ucurr_register (const UChar *isoCode, const char *locale, UErrorCode *status) |
Register an (existing) ISO 4217 currency code for the given locale. | |
U_CAPI UBool | ucurr_unregister (UCurrRegistryKey key, UErrorCode *status) |
Unregister the previously-registered currency definitions using the URegistryKey returned from ucurr_register. | |
U_CAPI const UChar * | ucurr_getName (const UChar *currency, const char *locale, UCurrNameStyle nameStyle, UBool *isChoiceFormat, int32_t *len, UErrorCode *ec) |
Returns the display name for the given currency in the given locale. | |
U_CAPI const UChar * | ucurr_getPluralName (const UChar *currency, const char *locale, UBool *isChoiceFormat, const char *pluralCount, int32_t *len, UErrorCode *ec) |
Returns the plural name for the given currency in the given locale. | |
U_CAPI int32_t | ucurr_getDefaultFractionDigits (const UChar *currency, UErrorCode *ec) |
Returns the number of the number of fraction digits that should be displayed for the given currency. | |
U_CAPI int32_t | ucurr_getDefaultFractionDigitsForUsage (const UChar *currency, const UCurrencyUsage usage, UErrorCode *ec) |
Returns the number of the number of fraction digits that should be displayed for the given currency with usage. | |
U_CAPI double | ucurr_getRoundingIncrement (const UChar *currency, UErrorCode *ec) |
Returns the rounding increment for the given currency, or 0.0 if no rounding is done by the currency. | |
U_CAPI double | ucurr_getRoundingIncrementForUsage (const UChar *currency, const UCurrencyUsage usage, UErrorCode *ec) |
Returns the rounding increment for the given currency, or 0.0 if no rounding is done by the currency given usage. | |
U_CAPI UEnumeration * | ucurr_openISOCurrencies (uint32_t currType, UErrorCode *pErrorCode) |
Provides a UEnumeration object for listing ISO-4217 codes. | |
U_CAPI UBool | ucurr_isAvailable (const UChar *isoCode, UDate from, UDate to, UErrorCode *errorCode) |
Queries if the given ISO 4217 3-letter code is available on the specified date range. | |
U_CAPI int32_t | ucurr_countCurrencies (const char *locale, UDate date, UErrorCode *ec) |
Finds the number of valid currency codes for the given locale and date. | |
U_CAPI int32_t | ucurr_forLocaleAndDate (const char *locale, UDate date, int32_t index, UChar *buff, int32_t buffCapacity, UErrorCode *ec) |
Finds a currency code for the given locale and date. | |
U_CAPI UEnumeration * | ucurr_getKeywordValuesForLocale (const char *key, const char *locale, UBool commonlyUsed, UErrorCode *status) |
Given a key and a locale, returns an array of string values in a preferred order that would make a difference. | |
U_CAPI int32_t | ucurr_getNumericCode (const UChar *currency) |
Returns the ISO 4217 numeric code for the currency. | |
C API: Encapsulates information about a currency.
The ucurr API encapsulates information about a currency, as defined by ISO 4217. A currency is represented by a 3-character string containing its ISO 4217 code. This API can return various data necessary the proper display of a currency:
The DecimalFormat
class uses these data to display currencies.
Definition in file ucurr.h.
typedef enum UCurrCurrencyType UCurrCurrencyType |
typedef enum UCurrencyUsage UCurrencyUsage |
typedef enum UCurrNameStyle UCurrNameStyle |
typedef const void* UCurrRegistryKey |
enum UCurrCurrencyType |
Selector constants for ucurr_openCurrencies().
Enumerator | |
---|---|
UCURR_ALL | Select all ISO-4217 currency codes.
|
UCURR_COMMON | Select only ISO-4217 commonly used currency codes. These currencies can be found in common use, and they usually have bank notes or coins associated with the currency code. This does not include fund codes, precious metals and other various ISO-4217 codes limited to special financial products.
|
UCURR_UNCOMMON | Select ISO-4217 uncommon currency codes. These codes respresent fund codes, precious metals and other various ISO-4217 codes limited to special financial products. A fund code is a monetary resource associated with a currency.
|
UCURR_DEPRECATED | Select only deprecated ISO-4217 codes. These codes are no longer in general public use.
|
UCURR_NON_DEPRECATED | Select only non-deprecated ISO-4217 codes. These codes are in general public use.
|
enum UCurrencyUsage |
Currency Usage used for Decimal Format.
Enumerator | |
---|---|
UCURR_USAGE_STANDARD | a setting to specify currency usage which determines currency digit and rounding for standard usage, for example: "50.00 NT$" used as DEFAULT value
|
UCURR_USAGE_CASH | a setting to specify currency usage which determines currency digit and rounding for cash usage, for example: "50 NT$"
|
UCURR_USAGE_COUNT | One higher than the last enum UCurrencyUsage constant.
|
enum UCurrNameStyle |
Selector constants for ucurr_getName().
Enumerator | |
---|---|
UCURR_SYMBOL_NAME | Selector for ucurr_getName indicating a symbolic name for a currency, such as "$" for USD.
|
UCURR_LONG_NAME | Selector for ucurr_getName indicating the long name for a currency, such as "US Dollar" for USD.
|
UCURR_NARROW_SYMBOL_NAME | Selector for getName() indicating the narrow currency symbol. The narrow currency symbol is similar to the regular currency symbol, but it always takes the shortest form: for example, "$" instead of "US$" for USD in en-CA.
|
UCURR_FORMAL_SYMBOL_NAME | Selector for getName() indicating the formal currency symbol. The formal currency symbol is similar to the regular currency symbol, but it always takes the form used in formal settings such as banking; for example, "NT$" instead of "$" for TWD in zh-TW.
|
UCURR_VARIANT_SYMBOL_NAME | Selector for getName() indicating the variant currency symbol. The variant symbol for a currency is an alternative symbol that is not necessarily as widely used as the regular symbol.
|
U_CAPI int32_t ucurr_countCurrencies | ( | const char * | locale, |
UDate | date, | ||
UErrorCode * | ec | ||
) |
Finds the number of valid currency codes for the given locale and date.
locale | the locale for which to retrieve the currency count. |
date | the date for which to retrieve the currency count for the given locale. |
ec | error code |
U_CAPI int32_t ucurr_forLocale | ( | const char * | locale, |
UChar * | buff, | ||
int32_t | buffCapacity, | ||
UErrorCode * | ec | ||
) |
Finds a currency code for the given locale.
locale | the locale for which to retrieve a currency code. Currency can be specified by the "currency" keyword in which case it overrides the default currency code |
buff | fill in buffer. Can be NULL for preflighting. |
buffCapacity | capacity of the fill in buffer. Can be 0 for preflighting. If it is non-zero, the buff parameter must not be NULL. |
ec | error code |
U_CAPI int32_t ucurr_forLocaleAndDate | ( | const char * | locale, |
UDate | date, | ||
int32_t | index, | ||
UChar * | buff, | ||
int32_t | buffCapacity, | ||
UErrorCode * | ec | ||
) |
Finds a currency code for the given locale and date.
locale | the locale for which to retrieve a currency code. Currency can be specified by the "currency" keyword in which case it overrides the default currency code |
date | the date for which to retrieve a currency code for the given locale. |
index | the index within the available list of currency codes for the given locale on the given date. |
buff | fill in buffer. Can be NULL for preflighting. |
buffCapacity | capacity of the fill in buffer. Can be 0 for preflighting. If it is non-zero, the buff parameter must not be NULL. |
ec | error code |
U_CAPI int32_t ucurr_getDefaultFractionDigits | ( | const UChar * | currency, |
UErrorCode * | ec | ||
) |
Returns the number of the number of fraction digits that should be displayed for the given currency.
This is equivalent to ucurr_getDefaultFractionDigitsForUsage(currency,UCURR_USAGE_STANDARD,ec);
Important: The number of fraction digits for a given currency is NOT guaranteed to be constant across versions of ICU or CLDR. For example, do NOT use this value as a mechanism for deciding the magnitude used to store currency values in a database. You should use this value for display purposes only.
currency | null-terminated 3-letter ISO 4217 code |
ec | input-output error code |
U_CAPI int32_t ucurr_getDefaultFractionDigitsForUsage | ( | const UChar * | currency, |
const UCurrencyUsage | usage, | ||
UErrorCode * | ec | ||
) |
Returns the number of the number of fraction digits that should be displayed for the given currency with usage.
Important: The number of fraction digits for a given currency is NOT guaranteed to be constant across versions of ICU or CLDR. For example, do NOT use this value as a mechanism for deciding the magnitude used to store currency values in a database. You should use this value for display purposes only.
currency | null-terminated 3-letter ISO 4217 code |
usage | enum usage for the currency |
ec | input-output error code |
U_CAPI UEnumeration * ucurr_getKeywordValuesForLocale | ( | const char * | key, |
const char * | locale, | ||
UBool | commonlyUsed, | ||
UErrorCode * | status | ||
) |
Given a key and a locale, returns an array of string values in a preferred order that would make a difference.
These are all and only those values where the open (creation) of the service with the locale formed from the input locale plus input keyword and that value has different behavior than creation with the input locale alone.
key | one of the keys supported by this service. For now, only "currency" is supported. |
locale | the locale |
commonlyUsed | if set to true it will return only commonly used values with the given locale in preferred order. Otherwise, it will return all the available values for the locale. |
status | error status |
U_CAPI const UChar * ucurr_getName | ( | const UChar * | currency, |
const char * | locale, | ||
UCurrNameStyle | nameStyle, | ||
UBool * | isChoiceFormat, | ||
int32_t * | len, | ||
UErrorCode * | ec | ||
) |
Returns the display name for the given currency in the given locale.
For example, the display name for the USD currency object in the en_US locale is "$".
currency | null-terminated 3-letter ISO 4217 code |
locale | locale in which to display currency |
nameStyle | selector for which kind of name to return |
isChoiceFormat | always set to false, or can be NULL; display names are static strings; since ICU 4.4, ChoiceFormat patterns are no longer supported |
len | fill-in parameter to receive length of result |
ec | error code |
Returns the ISO 4217 numeric code for the currency.
Note: If the ISO 4217 numeric code is not assigned for the currency or the currency is unknown, this function returns 0.
currency | null-terminated 3-letter ISO 4217 code |
U_CAPI const UChar * ucurr_getPluralName | ( | const UChar * | currency, |
const char * | locale, | ||
UBool * | isChoiceFormat, | ||
const char * | pluralCount, | ||
int32_t * | len, | ||
UErrorCode * | ec | ||
) |
Returns the plural name for the given currency in the given locale.
For example, the plural name for the USD currency object in the en_US locale is "US dollar" or "US dollars".
currency | null-terminated 3-letter ISO 4217 code |
locale | locale in which to display currency |
isChoiceFormat | always set to false, or can be NULL; display names are static strings; since ICU 4.4, ChoiceFormat patterns are no longer supported |
pluralCount | plural count |
len | fill-in parameter to receive length of result |
ec | error code |
U_CAPI double ucurr_getRoundingIncrement | ( | const UChar * | currency, |
UErrorCode * | ec | ||
) |
Returns the rounding increment for the given currency, or 0.0 if no rounding is done by the currency.
This is equivalent to ucurr_getRoundingIncrementForUsage(currency,UCURR_USAGE_STANDARD,ec);
currency | null-terminated 3-letter ISO 4217 code |
ec | input-output error code |
U_CAPI double ucurr_getRoundingIncrementForUsage | ( | const UChar * | currency, |
const UCurrencyUsage | usage, | ||
UErrorCode * | ec | ||
) |
Returns the rounding increment for the given currency, or 0.0 if no rounding is done by the currency given usage.
currency | null-terminated 3-letter ISO 4217 code |
usage | enum usage for the currency |
ec | input-output error code |
U_CAPI UBool ucurr_isAvailable | ( | const UChar * | isoCode, |
UDate | from, | ||
UDate | to, | ||
UErrorCode * | errorCode | ||
) |
Queries if the given ISO 4217 3-letter code is available on the specified date range.
Note: For checking availability of a currency on a specific date, specify the date on both 'from' and 'to'
When 'from' is U_DATE_MIN and 'to' is U_DATE_MAX, this method checks if the specified currency is available any time. If 'from' and 'to' are same UDate value, this method checks if the specified currency is available on that date.
isoCode | The ISO 4217 3-letter code. |
from | The lower bound of the date range, inclusive. When 'from' is U_DATE_MIN, check the availability of the currency any date before 'to' |
to | The upper bound of the date range, inclusive. When 'to' is U_DATE_MAX, check the availability of the currency any date after 'from' |
errorCode | ICU error code |
U_CAPI UEnumeration * ucurr_openISOCurrencies | ( | uint32_t | currType, |
UErrorCode * | pErrorCode | ||
) |
Provides a UEnumeration object for listing ISO-4217 codes.
currType | You can use one of several UCurrCurrencyType values for this variable. You can also | (or) them together to get a specific list of currencies. Most people will want to use the (UCURR_COMMON|UCURR_NON_DEPRECATED) value to get a list of current currencies. |
pErrorCode | Error code |
U_CAPI UCurrRegistryKey ucurr_register | ( | const UChar * | isoCode, |
const char * | locale, | ||
UErrorCode * | status | ||
) |
Register an (existing) ISO 4217 currency code for the given locale.
Only the country code and the two variants EURO and PRE_EURO are recognized.
isoCode | the three-letter ISO 4217 currency code |
locale | the locale for which to register this currency code |
status | the in/out status code |
U_CAPI UBool ucurr_unregister | ( | UCurrRegistryKey | key, |
UErrorCode * | status | ||
) |
Unregister the previously-registered currency definitions using the URegistryKey returned from ucurr_register.
Key becomes invalid after a successful call and should not be used again. Any currency that might have been hidden by the original ucurr_register call is restored.
key | the registry key returned by a previous call to ucurr_register |
status | the in/out status code, no special meanings are assigned |