ICU 72.1 72.1
Typedefs | Enumerations | Functions
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 enum UCurrencyUsage UCurrencyUsage
 Currency Usage used for Decimal Format. More...
 
typedef enum UCurrNameStyle UCurrNameStyle
 Selector constants for ucurr_getName(). More...
 
typedef const void * UCurrRegistryKey
 
typedef enum UCurrCurrencyType UCurrCurrencyType
 Selector constants for ucurr_openCurrencies(). More...
 

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. More...
 
U_CAPI UCurrRegistryKey ucurr_register (const UChar *isoCode, const char *locale, UErrorCode *status)
 Register an (existing) ISO 4217 currency code for the given locale. More...
 
U_CAPI UBool ucurr_unregister (UCurrRegistryKey key, UErrorCode *status)
 Unregister the previously-registered currency definitions using the URegistryKey returned from ucurr_register. More...
 
U_CAPI const UCharucurr_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. More...
 
U_CAPI const UCharucurr_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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
U_CAPI UEnumerationucurr_openISOCurrencies (uint32_t currType, UErrorCode *pErrorCode)
 Provides a UEnumeration object for listing ISO-4217 codes. More...
 
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. More...
 
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. More...
 
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. More...
 
U_CAPI UEnumerationucurr_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. More...
 
U_CAPI int32_t ucurr_getNumericCode (const UChar *currency)
 Returns the ISO 4217 numeric code for the currency. More...
 

Detailed Description

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.

Author
Alan Liu
Since
ICU 2.2

Definition in file ucurr.h.

Typedef Documentation

◆ UCurrCurrencyType

Selector constants for ucurr_openCurrencies().

See also
ucurr_openCurrencies
Stable:
ICU 3.2

◆ UCurrencyUsage

Currency Usage used for Decimal Format.

Definition at line 64 of file ucurr.h.

◆ UCurrNameStyle

Selector constants for ucurr_getName().

See also
ucurr_getName
Stable:
ICU 2.6

◆ UCurrRegistryKey

typedef const void* UCurrRegistryKey
Stable:
ICU 2.6

Definition at line 143 of file ucurr.h.

Enumeration Type Documentation

◆ 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 303 of file ucurr.h.

◆ UCurrencyUsage

Currency Usage used for Decimal Format.

Stable:
ICU 54
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

Stable:
ICU 54
UCURR_USAGE_CASH 

a setting to specify currency usage which determines currency digit and rounding for cash usage, for example: "50 NT$"

Stable:
ICU 54
UCURR_USAGE_COUNT 

One higher than the last enum UCurrencyUsage constant.

Deprecated:
ICU 58 The numeric value may change over time, see ICU ticket #12420.

Definition at line 41 of file ucurr.h.

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

Stable:
ICU 61
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.

Stable:
ICU 68
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.

Stable:
ICU 68

Definition at line 93 of file ucurr.h.

Function Documentation

◆ ucurr_countCurrencies()

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.

Parameters
localethe locale for which to retrieve the currency count.
datethe date for which to retrieve the currency count for the given locale.
ecerror 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

◆ ucurr_forLocale()

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

Finds a currency code for the given locale.

Parameters
localethe 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
bufffill in buffer. Can be NULL for preflighting.
buffCapacitycapacity of the fill in buffer. Can be 0 for preflighting. If it is non-zero, the buff parameter must not be NULL.
ecerror 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

◆ ucurr_forLocaleAndDate()

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.

Parameters
localethe 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
datethe date for which to retrieve a currency code for the given locale.
indexthe index within the available list of currency codes for the given locale on the given date.
bufffill in buffer. Can be NULL for preflighting.
buffCapacitycapacity of the fill in buffer. Can be 0 for preflighting. If it is non-zero, the buff parameter must not be NULL.
ecerror 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

◆ ucurr_getDefaultFractionDigits()

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.

Parameters
currencynull-terminated 3-letter ISO 4217 code
ecinput-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

◆ ucurr_getDefaultFractionDigitsForUsage()

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.

Parameters
currencynull-terminated 3-letter ISO 4217 code
usageenum usage for the currency
ecinput-output error code
Returns
a non-negative number of fraction digits to be displayed, or 0 if there is an error
Stable:
ICU 54

◆ ucurr_getKeywordValuesForLocale()

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.

Parameters
keyone of the keys supported by this service. For now, only "currency" is supported.
localethe locale
commonlyUsedif 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.
statuserror status
Returns
a string enumeration over keyword values for the given key and the locale.
Stable:
ICU 4.2

◆ ucurr_getName()

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

Parameters
currencynull-terminated 3-letter ISO 4217 code
localelocale in which to display currency
nameStyleselector for which kind of name to return
isChoiceFormatalways set to false, or can be NULL; display names are static strings; since ICU 4.4, ChoiceFormat patterns are no longer supported
lenfill-in parameter to receive length of result
ecerror code
Returns
pointer to display string of 'len' UChars. If the resource data contains no entry for 'currency', then 'currency' itself is returned.
Stable:
ICU 2.6

◆ ucurr_getNumericCode()

U_CAPI int32_t ucurr_getNumericCode ( const UChar currency)

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.

Parameters
currencynull-terminated 3-letter ISO 4217 code
Returns
The ISO 4217 numeric code of the currency
Stable:
ICU 49

◆ ucurr_getPluralName()

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

Parameters
currencynull-terminated 3-letter ISO 4217 code
localelocale in which to display currency
isChoiceFormatalways set to false, or can be NULL; display names are static strings; since ICU 4.4, ChoiceFormat patterns are no longer supported
pluralCountplural count
lenfill-in parameter to receive length of result
ecerror code
Returns
pointer to display string of 'len' UChars. If the resource data contains no entry for 'currency', then 'currency' itself is returned.
Stable:
ICU 4.2

◆ ucurr_getRoundingIncrement()

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);

Parameters
currencynull-terminated 3-letter ISO 4217 code
ecinput-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

◆ ucurr_getRoundingIncrementForUsage()

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.

Parameters
currencynull-terminated 3-letter ISO 4217 code
usageenum usage for the currency
ecinput-output error code
Returns
the non-negative rounding increment, or 0.0 if none, or 0.0 if there is an error
Stable:
ICU 54

◆ ucurr_isAvailable()

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.

Parameters
isoCodeThe ISO 4217 3-letter code.
fromThe lower bound of the date range, inclusive. When 'from' is U_DATE_MIN, check the availability of the currency any date before 'to'
toThe upper bound of the date range, inclusive. When 'to' is U_DATE_MAX, check the availability of the currency any date after 'from'
errorCodeICU error code
Returns
true if the given ISO 4217 3-letter code is supported on the specified date range.
Stable:
ICU 4.8

◆ ucurr_openISOCurrencies()

U_CAPI UEnumeration * ucurr_openISOCurrencies ( uint32_t  currType,
UErrorCode pErrorCode 
)

Provides a UEnumeration object for listing ISO-4217 codes.

Parameters
currTypeYou 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.
pErrorCodeError code
Stable:
ICU 3.2

◆ ucurr_register()

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.

Parameters
isoCodethe three-letter ISO 4217 currency code
localethe locale for which to register this currency code
statusthe 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

◆ ucurr_unregister()

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.

Parameters
keythe registry key returned by a previous call to ucurr_register
statusthe in/out status code, no special meanings are assigned
Returns
true if the currency for this key was successfully unregistered
Stable:
ICU 2.6