# ucurr.h File Reference

C API: Encapsulates information about a currency. More...

`#include "unicode/utypes.h"`
`#include "unicode/uenum.h"`

Go to the source code of this file.

## Typedefs
typedef const void * | UCurrRegistryKey
## Enumerations
enum | UCurrNameStyle { UCURR_SYMBOL_NAME, UCURR_LONG_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
int32_t | ucurr_forLocale (const char *locale, UChar *buff, int32_t buffCapacity, UErrorCode *ec)
| The ucurr API encapsulates information about a currency, as defined by ISO 4217.
UCurrRegistryKey | ucurr_register (const UChar *isoCode, const char *locale, UErrorCode *status)
| Register an (existing) ISO 4217 currency code for the given locale.
UBool | ucurr_unregister (UCurrRegistryKey key, UErrorCode *status)
| Unregister the previously-registered currency definitions using the URegistryKey returned from ucurr_register.
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.
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.
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.
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.
UEnumeration * | ucurr_openISOCurrencies (uint32_t currType, UErrorCode *pErrorCode)
| Provides a UEnumeration object for listing ISO-4217 codes.
int32_t | ucurr_countCurrencies (const char *locale, UDate date, UErrorCode *ec)
| Finds the number of valid currency codes for the given locale and date.
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.
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.

## Detailed Description

C API: Encapsulates information about a currency.

Definition in file ucurr.h.

## Typedef Documentation

typedef const void* UCurrRegistryKey

Stable:
  ICU 2.6

Definition at line 84 of file ucurr.h.

## Enumeration Type Documentation

enum UCurrCurrencyType

Selector constants for ucurr_openCurrencies().

See also:
  ucurr_openCurrencies

Stable:
  ICU 3.2

Enumerator:

  UCURR_ALL | Select all ISO-4217 currency codes. Stable: ICU 3.2
  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. Stable: ICU 3.2
  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. Stable: ICU 3.2
  UCURR_DEPRECATED | Select only deprecated ISO-4217 codes. These codes are no longer in general public use. Stable: ICU 3.2
  UCURR_NON_DEPRECATED | Select only non-deprecated ISO-4217 codes. These codes are in general public use. Stable: ICU 3.2

Definition at line 197 of file ucurr.h.

enum UCurrNameStyle

Selector constants for ucurr_getName().

See also:
  ucurr_getName

Stable:
  ICU 2.6

Enumerator:

  UCURR_SYMBOL_NAME | Selector for ucurr_getName indicating a symbolic name for a currency, such as "$" for USD. Stable: ICU 2.6
  UCURR_LONG_NAME | Selector for ucurr_getName indicating the long name for a currency, such as "US Dollar" for USD. Stable: ICU 2.6

Definition at line 64 of file ucurr.h.

## Function Documentation

int32_t ucurr_countCurrencies | ( | const char * | locale,
|  | UDate | date,
|  | UErrorCode * | ec |
| ) |  |  |

Finds the number of valid currency codes for the given locale and date.

Parameters:

  | 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

Returns:
  the number of currency codes for the given locale and date. If 0, currency codes couldn't be found for the input values are invalid.

Stable:
  ICU 4.0

int32_t ucurr_forLocale | ( | const char * | locale,
|  | UChar * | buff,
|  | int32_t | buffCapacity,
|  | UErrorCode * | ec |
| ) |  |  |

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:

- A display symbol, for a specific locale
- The number of fraction digits to display
- A rounding increment

The `DecimalFormat` class uses these data to display currencies.

Author:
  Alan Liu

Since:
  ICU 2.2 Finds a currency code for the given locale.

Parameters:

  | 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

Returns:
  length of the currency string. It should always be 3. If 0, currency couldn't be found or the input values are invalid.

Stable:
  ICU 2.8

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.

Parameters:

  | 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

Returns:
  length of the currency string. It should always be 3. If 0, currency couldn't be found or the input values are invalid.

Stable:
  ICU 4.0

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.

Parameters:

  | currency | null-terminated 3-letter ISO 4217 code
  | ec | input-output error code

Returns:
  a non-negative number of fraction digits to be displayed, or 0 if there is an error

Stable:
  ICU 3.0

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.

Parameters:

  | 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

Returns:
  a string enumeration over keyword values for the given key and the locale.

Draft:
  This API may be changed in the future versions and was introduced in ICU 4.2

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 "$".

Parameters:

  | 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 | fill-in set to TRUE if the returned value is a ChoiceFormat pattern; otherwise it is a static string
  | len | fill-in parameter to receive length of result
  | ec | error code

Returns:
  pointer to display string of 'len' UChars. If the resource data contains no entry for 'currency', then 'currency' itself is returned. If *isChoiceFormat is TRUE, then the result is a ChoiceFormat pattern. Otherwise it is a static string.

Stable:
  ICU 2.6

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".

Parameters:

  | currency | null-terminated 3-letter ISO 4217 code
  | locale | locale in which to display currency
  | isChoiceFormat | fill-in set to TRUE if the returned value is a ChoiceFormat pattern; otherwise it is a static string
  | pluralCount | plural count
  | len | fill-in parameter to receive length of result
  | ec | error code

Returns:
  pointer to display string of 'len' UChars. If the resource data contains no entry for 'currency', then 'currency' itself is returned.

Draft:
  This API may be changed in the future versions and was introduced in ICU 4.2

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.

Parameters:

  | currency | null-terminated 3-letter ISO 4217 code
  | ec | input-output error code

Returns:
  the non-negative rounding increment, or 0.0 if none, or 0.0 if there is an error

Stable:
  ICU 3.0

UEnumeration* ucurr_openISOCurrencies | ( | uint32_t | currType,
|  | UErrorCode * | pErrorCode |
| ) |  |  |

Provides a UEnumeration object for listing ISO-4217 codes.

Parameters:

  | 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_CURRENCY|UCURR_NON_DEPRECATED) value to get a list of current currencies.
  | pErrorCode | Error code

Stable:
  ICU 3.2

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.

Parameters:

  | isoCode | the three-letter ISO 4217 currency code
  | locale | the locale for which to register this currency code
  | status | the in/out status code

Returns:
  a registry key that can be used to unregister this currency code, or NULL if there was an error.

Stable:
  ICU 2.6

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.

Parameters:

  | key | the registry key returned by a previous call to ucurr_register
  | status | the in/out status code, no special meanings are assigned

Returns:
  TRUE if the currency for this key was successfully unregistered

Stable:
  ICU 2.6