1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /* 4*0e209d39SAndroid Build Coastguard Worker ********************************************************************** 5*0e209d39SAndroid Build Coastguard Worker * Copyright (c) 2002-2016, International Business Machines 6*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved. 7*0e209d39SAndroid Build Coastguard Worker ********************************************************************** 8*0e209d39SAndroid Build Coastguard Worker */ 9*0e209d39SAndroid Build Coastguard Worker #ifndef _UCURR_H_ 10*0e209d39SAndroid Build Coastguard Worker #define _UCURR_H_ 11*0e209d39SAndroid Build Coastguard Worker 12*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 13*0e209d39SAndroid Build Coastguard Worker #include "unicode/uenum.h" 14*0e209d39SAndroid Build Coastguard Worker 15*0e209d39SAndroid Build Coastguard Worker /** 16*0e209d39SAndroid Build Coastguard Worker * \file 17*0e209d39SAndroid Build Coastguard Worker * \brief C API: Encapsulates information about a currency. 18*0e209d39SAndroid Build Coastguard Worker * 19*0e209d39SAndroid Build Coastguard Worker * The ucurr API encapsulates information about a currency, as defined by 20*0e209d39SAndroid Build Coastguard Worker * ISO 4217. A currency is represented by a 3-character string 21*0e209d39SAndroid Build Coastguard Worker * containing its ISO 4217 code. This API can return various data 22*0e209d39SAndroid Build Coastguard Worker * necessary the proper display of a currency: 23*0e209d39SAndroid Build Coastguard Worker * 24*0e209d39SAndroid Build Coastguard Worker * <ul><li>A display symbol, for a specific locale 25*0e209d39SAndroid Build Coastguard Worker * <li>The number of fraction digits to display 26*0e209d39SAndroid Build Coastguard Worker * <li>A rounding increment 27*0e209d39SAndroid Build Coastguard Worker * </ul> 28*0e209d39SAndroid Build Coastguard Worker * 29*0e209d39SAndroid Build Coastguard Worker * The <tt>DecimalFormat</tt> class uses these data to display 30*0e209d39SAndroid Build Coastguard Worker * currencies. 31*0e209d39SAndroid Build Coastguard Worker * @author Alan Liu 32*0e209d39SAndroid Build Coastguard Worker * @since ICU 2.2 33*0e209d39SAndroid Build Coastguard Worker */ 34*0e209d39SAndroid Build Coastguard Worker 35*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING 36*0e209d39SAndroid Build Coastguard Worker 37*0e209d39SAndroid Build Coastguard Worker /** 38*0e209d39SAndroid Build Coastguard Worker * Currency Usage used for Decimal Format 39*0e209d39SAndroid Build Coastguard Worker * @stable ICU 54 40*0e209d39SAndroid Build Coastguard Worker */ 41*0e209d39SAndroid Build Coastguard Worker enum UCurrencyUsage { 42*0e209d39SAndroid Build Coastguard Worker /** 43*0e209d39SAndroid Build Coastguard Worker * a setting to specify currency usage which determines currency digit 44*0e209d39SAndroid Build Coastguard Worker * and rounding for standard usage, for example: "50.00 NT$" 45*0e209d39SAndroid Build Coastguard Worker * used as DEFAULT value 46*0e209d39SAndroid Build Coastguard Worker * @stable ICU 54 47*0e209d39SAndroid Build Coastguard Worker */ 48*0e209d39SAndroid Build Coastguard Worker UCURR_USAGE_STANDARD=0, 49*0e209d39SAndroid Build Coastguard Worker /** 50*0e209d39SAndroid Build Coastguard Worker * a setting to specify currency usage which determines currency digit 51*0e209d39SAndroid Build Coastguard Worker * and rounding for cash usage, for example: "50 NT$" 52*0e209d39SAndroid Build Coastguard Worker * @stable ICU 54 53*0e209d39SAndroid Build Coastguard Worker */ 54*0e209d39SAndroid Build Coastguard Worker UCURR_USAGE_CASH=1, 55*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 56*0e209d39SAndroid Build Coastguard Worker /** 57*0e209d39SAndroid Build Coastguard Worker * One higher than the last enum UCurrencyUsage constant. 58*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. 59*0e209d39SAndroid Build Coastguard Worker */ 60*0e209d39SAndroid Build Coastguard Worker UCURR_USAGE_COUNT=2 61*0e209d39SAndroid Build Coastguard Worker #endif // U_HIDE_DEPRECATED_API 62*0e209d39SAndroid Build Coastguard Worker }; 63*0e209d39SAndroid Build Coastguard Worker /** Currency Usage used for Decimal Format */ 64*0e209d39SAndroid Build Coastguard Worker typedef enum UCurrencyUsage UCurrencyUsage; 65*0e209d39SAndroid Build Coastguard Worker 66*0e209d39SAndroid Build Coastguard Worker /** 67*0e209d39SAndroid Build Coastguard Worker * Finds a currency code for the given locale. 68*0e209d39SAndroid Build Coastguard Worker * @param locale the locale for which to retrieve a currency code. 69*0e209d39SAndroid Build Coastguard Worker * Currency can be specified by the "currency" keyword 70*0e209d39SAndroid Build Coastguard Worker * in which case it overrides the default currency code 71*0e209d39SAndroid Build Coastguard Worker * @param buff fill in buffer. Can be NULL for preflighting. 72*0e209d39SAndroid Build Coastguard Worker * @param buffCapacity capacity of the fill in buffer. Can be 0 for 73*0e209d39SAndroid Build Coastguard Worker * preflighting. If it is non-zero, the buff parameter 74*0e209d39SAndroid Build Coastguard Worker * must not be NULL. 75*0e209d39SAndroid Build Coastguard Worker * @param ec error code 76*0e209d39SAndroid Build Coastguard Worker * @return length of the currency string. It should always be 3. If 0, 77*0e209d39SAndroid Build Coastguard Worker * currency couldn't be found or the input values are 78*0e209d39SAndroid Build Coastguard Worker * invalid. 79*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.8 80*0e209d39SAndroid Build Coastguard Worker */ 81*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 82*0e209d39SAndroid Build Coastguard Worker ucurr_forLocale(const char* locale, 83*0e209d39SAndroid Build Coastguard Worker UChar* buff, 84*0e209d39SAndroid Build Coastguard Worker int32_t buffCapacity, 85*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec); 86*0e209d39SAndroid Build Coastguard Worker 87*0e209d39SAndroid Build Coastguard Worker /** 88*0e209d39SAndroid Build Coastguard Worker * Selector constants for ucurr_getName(). 89*0e209d39SAndroid Build Coastguard Worker * 90*0e209d39SAndroid Build Coastguard Worker * @see ucurr_getName 91*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6 92*0e209d39SAndroid Build Coastguard Worker */ 93*0e209d39SAndroid Build Coastguard Worker typedef enum UCurrNameStyle { 94*0e209d39SAndroid Build Coastguard Worker /** 95*0e209d39SAndroid Build Coastguard Worker * Selector for ucurr_getName indicating a symbolic name for a 96*0e209d39SAndroid Build Coastguard Worker * currency, such as "$" for USD. 97*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6 98*0e209d39SAndroid Build Coastguard Worker */ 99*0e209d39SAndroid Build Coastguard Worker UCURR_SYMBOL_NAME, 100*0e209d39SAndroid Build Coastguard Worker 101*0e209d39SAndroid Build Coastguard Worker /** 102*0e209d39SAndroid Build Coastguard Worker * Selector for ucurr_getName indicating the long name for a 103*0e209d39SAndroid Build Coastguard Worker * currency, such as "US Dollar" for USD. 104*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6 105*0e209d39SAndroid Build Coastguard Worker */ 106*0e209d39SAndroid Build Coastguard Worker UCURR_LONG_NAME, 107*0e209d39SAndroid Build Coastguard Worker 108*0e209d39SAndroid Build Coastguard Worker /** 109*0e209d39SAndroid Build Coastguard Worker * Selector for getName() indicating the narrow currency symbol. 110*0e209d39SAndroid Build Coastguard Worker * The narrow currency symbol is similar to the regular currency 111*0e209d39SAndroid Build Coastguard Worker * symbol, but it always takes the shortest form: for example, 112*0e209d39SAndroid Build Coastguard Worker * "$" instead of "US$" for USD in en-CA. 113*0e209d39SAndroid Build Coastguard Worker * 114*0e209d39SAndroid Build Coastguard Worker * @stable ICU 61 115*0e209d39SAndroid Build Coastguard Worker */ 116*0e209d39SAndroid Build Coastguard Worker UCURR_NARROW_SYMBOL_NAME, 117*0e209d39SAndroid Build Coastguard Worker 118*0e209d39SAndroid Build Coastguard Worker /** 119*0e209d39SAndroid Build Coastguard Worker * Selector for getName() indicating the formal currency symbol. 120*0e209d39SAndroid Build Coastguard Worker * The formal currency symbol is similar to the regular currency 121*0e209d39SAndroid Build Coastguard Worker * symbol, but it always takes the form used in formal settings 122*0e209d39SAndroid Build Coastguard Worker * such as banking; for example, "NT$" instead of "$" for TWD in zh-TW. 123*0e209d39SAndroid Build Coastguard Worker * 124*0e209d39SAndroid Build Coastguard Worker * @stable ICU 68 125*0e209d39SAndroid Build Coastguard Worker */ 126*0e209d39SAndroid Build Coastguard Worker UCURR_FORMAL_SYMBOL_NAME, 127*0e209d39SAndroid Build Coastguard Worker 128*0e209d39SAndroid Build Coastguard Worker /** 129*0e209d39SAndroid Build Coastguard Worker * Selector for getName() indicating the variant currency symbol. 130*0e209d39SAndroid Build Coastguard Worker * The variant symbol for a currency is an alternative symbol 131*0e209d39SAndroid Build Coastguard Worker * that is not necessarily as widely used as the regular symbol. 132*0e209d39SAndroid Build Coastguard Worker * 133*0e209d39SAndroid Build Coastguard Worker * @stable ICU 68 134*0e209d39SAndroid Build Coastguard Worker */ 135*0e209d39SAndroid Build Coastguard Worker UCURR_VARIANT_SYMBOL_NAME 136*0e209d39SAndroid Build Coastguard Worker 137*0e209d39SAndroid Build Coastguard Worker } UCurrNameStyle; 138*0e209d39SAndroid Build Coastguard Worker 139*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_SERVICE 140*0e209d39SAndroid Build Coastguard Worker /** 141*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6 142*0e209d39SAndroid Build Coastguard Worker */ 143*0e209d39SAndroid Build Coastguard Worker typedef const void* UCurrRegistryKey; 144*0e209d39SAndroid Build Coastguard Worker 145*0e209d39SAndroid Build Coastguard Worker /** 146*0e209d39SAndroid Build Coastguard Worker * Register an (existing) ISO 4217 currency code for the given locale. 147*0e209d39SAndroid Build Coastguard Worker * Only the country code and the two variants EURO and PRE_EURO are 148*0e209d39SAndroid Build Coastguard Worker * recognized. 149*0e209d39SAndroid Build Coastguard Worker * @param isoCode the three-letter ISO 4217 currency code 150*0e209d39SAndroid Build Coastguard Worker * @param locale the locale for which to register this currency code 151*0e209d39SAndroid Build Coastguard Worker * @param status the in/out status code 152*0e209d39SAndroid Build Coastguard Worker * @return a registry key that can be used to unregister this currency code, or NULL 153*0e209d39SAndroid Build Coastguard Worker * if there was an error. 154*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6 155*0e209d39SAndroid Build Coastguard Worker */ 156*0e209d39SAndroid Build Coastguard Worker U_CAPI UCurrRegistryKey U_EXPORT2 157*0e209d39SAndroid Build Coastguard Worker ucurr_register(const UChar* isoCode, 158*0e209d39SAndroid Build Coastguard Worker const char* locale, 159*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 160*0e209d39SAndroid Build Coastguard Worker /** 161*0e209d39SAndroid Build Coastguard Worker * Unregister the previously-registered currency definitions using the 162*0e209d39SAndroid Build Coastguard Worker * URegistryKey returned from ucurr_register. Key becomes invalid after 163*0e209d39SAndroid Build Coastguard Worker * a successful call and should not be used again. Any currency 164*0e209d39SAndroid Build Coastguard Worker * that might have been hidden by the original ucurr_register call is 165*0e209d39SAndroid Build Coastguard Worker * restored. 166*0e209d39SAndroid Build Coastguard Worker * @param key the registry key returned by a previous call to ucurr_register 167*0e209d39SAndroid Build Coastguard Worker * @param status the in/out status code, no special meanings are assigned 168*0e209d39SAndroid Build Coastguard Worker * @return true if the currency for this key was successfully unregistered 169*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6 170*0e209d39SAndroid Build Coastguard Worker */ 171*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 172*0e209d39SAndroid Build Coastguard Worker ucurr_unregister(UCurrRegistryKey key, UErrorCode* status); 173*0e209d39SAndroid Build Coastguard Worker #endif /* UCONFIG_NO_SERVICE */ 174*0e209d39SAndroid Build Coastguard Worker 175*0e209d39SAndroid Build Coastguard Worker /** 176*0e209d39SAndroid Build Coastguard Worker * Returns the display name for the given currency in the 177*0e209d39SAndroid Build Coastguard Worker * given locale. For example, the display name for the USD 178*0e209d39SAndroid Build Coastguard Worker * currency object in the en_US locale is "$". 179*0e209d39SAndroid Build Coastguard Worker * @param currency null-terminated 3-letter ISO 4217 code 180*0e209d39SAndroid Build Coastguard Worker * @param locale locale in which to display currency 181*0e209d39SAndroid Build Coastguard Worker * @param nameStyle selector for which kind of name to return 182*0e209d39SAndroid Build Coastguard Worker * @param isChoiceFormat always set to false, or can be NULL; 183*0e209d39SAndroid Build Coastguard Worker * display names are static strings; 184*0e209d39SAndroid Build Coastguard Worker * since ICU 4.4, ChoiceFormat patterns are no longer supported 185*0e209d39SAndroid Build Coastguard Worker * @param len fill-in parameter to receive length of result 186*0e209d39SAndroid Build Coastguard Worker * @param ec error code 187*0e209d39SAndroid Build Coastguard Worker * @return pointer to display string of 'len' UChars. If the resource 188*0e209d39SAndroid Build Coastguard Worker * data contains no entry for 'currency', then 'currency' itself is 189*0e209d39SAndroid Build Coastguard Worker * returned. 190*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6 191*0e209d39SAndroid Build Coastguard Worker */ 192*0e209d39SAndroid Build Coastguard Worker U_CAPI const UChar* U_EXPORT2 193*0e209d39SAndroid Build Coastguard Worker ucurr_getName(const UChar* currency, 194*0e209d39SAndroid Build Coastguard Worker const char* locale, 195*0e209d39SAndroid Build Coastguard Worker UCurrNameStyle nameStyle, 196*0e209d39SAndroid Build Coastguard Worker UBool* isChoiceFormat, 197*0e209d39SAndroid Build Coastguard Worker int32_t* len, 198*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec); 199*0e209d39SAndroid Build Coastguard Worker 200*0e209d39SAndroid Build Coastguard Worker /** 201*0e209d39SAndroid Build Coastguard Worker * Returns the plural name for the given currency in the 202*0e209d39SAndroid Build Coastguard Worker * given locale. For example, the plural name for the USD 203*0e209d39SAndroid Build Coastguard Worker * currency object in the en_US locale is "US dollar" or "US dollars". 204*0e209d39SAndroid Build Coastguard Worker * @param currency null-terminated 3-letter ISO 4217 code 205*0e209d39SAndroid Build Coastguard Worker * @param locale locale in which to display currency 206*0e209d39SAndroid Build Coastguard Worker * @param isChoiceFormat always set to false, or can be NULL; 207*0e209d39SAndroid Build Coastguard Worker * display names are static strings; 208*0e209d39SAndroid Build Coastguard Worker * since ICU 4.4, ChoiceFormat patterns are no longer supported 209*0e209d39SAndroid Build Coastguard Worker * @param pluralCount plural count 210*0e209d39SAndroid Build Coastguard Worker * @param len fill-in parameter to receive length of result 211*0e209d39SAndroid Build Coastguard Worker * @param ec error code 212*0e209d39SAndroid Build Coastguard Worker * @return pointer to display string of 'len' UChars. If the resource 213*0e209d39SAndroid Build Coastguard Worker * data contains no entry for 'currency', then 'currency' itself is 214*0e209d39SAndroid Build Coastguard Worker * returned. 215*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.2 216*0e209d39SAndroid Build Coastguard Worker */ 217*0e209d39SAndroid Build Coastguard Worker U_CAPI const UChar* U_EXPORT2 218*0e209d39SAndroid Build Coastguard Worker ucurr_getPluralName(const UChar* currency, 219*0e209d39SAndroid Build Coastguard Worker const char* locale, 220*0e209d39SAndroid Build Coastguard Worker UBool* isChoiceFormat, 221*0e209d39SAndroid Build Coastguard Worker const char* pluralCount, 222*0e209d39SAndroid Build Coastguard Worker int32_t* len, 223*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec); 224*0e209d39SAndroid Build Coastguard Worker 225*0e209d39SAndroid Build Coastguard Worker /** 226*0e209d39SAndroid Build Coastguard Worker * Returns the number of the number of fraction digits that should 227*0e209d39SAndroid Build Coastguard Worker * be displayed for the given currency. 228*0e209d39SAndroid Build Coastguard Worker * This is equivalent to ucurr_getDefaultFractionDigitsForUsage(currency,UCURR_USAGE_STANDARD,ec); 229*0e209d39SAndroid Build Coastguard Worker * 230*0e209d39SAndroid Build Coastguard Worker * Important: The number of fraction digits for a given currency is NOT 231*0e209d39SAndroid Build Coastguard Worker * guaranteed to be constant across versions of ICU or CLDR. For example, 232*0e209d39SAndroid Build Coastguard Worker * do NOT use this value as a mechanism for deciding the magnitude used 233*0e209d39SAndroid Build Coastguard Worker * to store currency values in a database. You should use this value for 234*0e209d39SAndroid Build Coastguard Worker * display purposes only. 235*0e209d39SAndroid Build Coastguard Worker * 236*0e209d39SAndroid Build Coastguard Worker * @param currency null-terminated 3-letter ISO 4217 code 237*0e209d39SAndroid Build Coastguard Worker * @param ec input-output error code 238*0e209d39SAndroid Build Coastguard Worker * @return a non-negative number of fraction digits to be 239*0e209d39SAndroid Build Coastguard Worker * displayed, or 0 if there is an error 240*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 241*0e209d39SAndroid Build Coastguard Worker */ 242*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 243*0e209d39SAndroid Build Coastguard Worker ucurr_getDefaultFractionDigits(const UChar* currency, 244*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec); 245*0e209d39SAndroid Build Coastguard Worker 246*0e209d39SAndroid Build Coastguard Worker /** 247*0e209d39SAndroid Build Coastguard Worker * Returns the number of the number of fraction digits that should 248*0e209d39SAndroid Build Coastguard Worker * be displayed for the given currency with usage. 249*0e209d39SAndroid Build Coastguard Worker * 250*0e209d39SAndroid Build Coastguard Worker * Important: The number of fraction digits for a given currency is NOT 251*0e209d39SAndroid Build Coastguard Worker * guaranteed to be constant across versions of ICU or CLDR. For example, 252*0e209d39SAndroid Build Coastguard Worker * do NOT use this value as a mechanism for deciding the magnitude used 253*0e209d39SAndroid Build Coastguard Worker * to store currency values in a database. You should use this value for 254*0e209d39SAndroid Build Coastguard Worker * display purposes only. 255*0e209d39SAndroid Build Coastguard Worker * 256*0e209d39SAndroid Build Coastguard Worker * @param currency null-terminated 3-letter ISO 4217 code 257*0e209d39SAndroid Build Coastguard Worker * @param usage enum usage for the currency 258*0e209d39SAndroid Build Coastguard Worker * @param ec input-output error code 259*0e209d39SAndroid Build Coastguard Worker * @return a non-negative number of fraction digits to be 260*0e209d39SAndroid Build Coastguard Worker * displayed, or 0 if there is an error 261*0e209d39SAndroid Build Coastguard Worker * @stable ICU 54 262*0e209d39SAndroid Build Coastguard Worker */ 263*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 264*0e209d39SAndroid Build Coastguard Worker ucurr_getDefaultFractionDigitsForUsage(const UChar* currency, 265*0e209d39SAndroid Build Coastguard Worker const UCurrencyUsage usage, 266*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec); 267*0e209d39SAndroid Build Coastguard Worker 268*0e209d39SAndroid Build Coastguard Worker /** 269*0e209d39SAndroid Build Coastguard Worker * Returns the rounding increment for the given currency, or 0.0 if no 270*0e209d39SAndroid Build Coastguard Worker * rounding is done by the currency. 271*0e209d39SAndroid Build Coastguard Worker * This is equivalent to ucurr_getRoundingIncrementForUsage(currency,UCURR_USAGE_STANDARD,ec); 272*0e209d39SAndroid Build Coastguard Worker * @param currency null-terminated 3-letter ISO 4217 code 273*0e209d39SAndroid Build Coastguard Worker * @param ec input-output error code 274*0e209d39SAndroid Build Coastguard Worker * @return the non-negative rounding increment, or 0.0 if none, 275*0e209d39SAndroid Build Coastguard Worker * or 0.0 if there is an error 276*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 277*0e209d39SAndroid Build Coastguard Worker */ 278*0e209d39SAndroid Build Coastguard Worker U_CAPI double U_EXPORT2 279*0e209d39SAndroid Build Coastguard Worker ucurr_getRoundingIncrement(const UChar* currency, 280*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec); 281*0e209d39SAndroid Build Coastguard Worker 282*0e209d39SAndroid Build Coastguard Worker /** 283*0e209d39SAndroid Build Coastguard Worker * Returns the rounding increment for the given currency, or 0.0 if no 284*0e209d39SAndroid Build Coastguard Worker * rounding is done by the currency given usage. 285*0e209d39SAndroid Build Coastguard Worker * @param currency null-terminated 3-letter ISO 4217 code 286*0e209d39SAndroid Build Coastguard Worker * @param usage enum usage for the currency 287*0e209d39SAndroid Build Coastguard Worker * @param ec input-output error code 288*0e209d39SAndroid Build Coastguard Worker * @return the non-negative rounding increment, or 0.0 if none, 289*0e209d39SAndroid Build Coastguard Worker * or 0.0 if there is an error 290*0e209d39SAndroid Build Coastguard Worker * @stable ICU 54 291*0e209d39SAndroid Build Coastguard Worker */ 292*0e209d39SAndroid Build Coastguard Worker U_CAPI double U_EXPORT2 293*0e209d39SAndroid Build Coastguard Worker ucurr_getRoundingIncrementForUsage(const UChar* currency, 294*0e209d39SAndroid Build Coastguard Worker const UCurrencyUsage usage, 295*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec); 296*0e209d39SAndroid Build Coastguard Worker 297*0e209d39SAndroid Build Coastguard Worker /** 298*0e209d39SAndroid Build Coastguard Worker * Selector constants for ucurr_openCurrencies(). 299*0e209d39SAndroid Build Coastguard Worker * 300*0e209d39SAndroid Build Coastguard Worker * @see ucurr_openCurrencies 301*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.2 302*0e209d39SAndroid Build Coastguard Worker */ 303*0e209d39SAndroid Build Coastguard Worker typedef enum UCurrCurrencyType { 304*0e209d39SAndroid Build Coastguard Worker /** 305*0e209d39SAndroid Build Coastguard Worker * Select all ISO-4217 currency codes. 306*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.2 307*0e209d39SAndroid Build Coastguard Worker */ 308*0e209d39SAndroid Build Coastguard Worker UCURR_ALL = INT32_MAX, 309*0e209d39SAndroid Build Coastguard Worker /** 310*0e209d39SAndroid Build Coastguard Worker * Select only ISO-4217 commonly used currency codes. 311*0e209d39SAndroid Build Coastguard Worker * These currencies can be found in common use, and they usually have 312*0e209d39SAndroid Build Coastguard Worker * bank notes or coins associated with the currency code. 313*0e209d39SAndroid Build Coastguard Worker * This does not include fund codes, precious metals and other 314*0e209d39SAndroid Build Coastguard Worker * various ISO-4217 codes limited to special financial products. 315*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.2 316*0e209d39SAndroid Build Coastguard Worker */ 317*0e209d39SAndroid Build Coastguard Worker UCURR_COMMON = 1, 318*0e209d39SAndroid Build Coastguard Worker /** 319*0e209d39SAndroid Build Coastguard Worker * Select ISO-4217 uncommon currency codes. 320*0e209d39SAndroid Build Coastguard Worker * These codes respresent fund codes, precious metals and other 321*0e209d39SAndroid Build Coastguard Worker * various ISO-4217 codes limited to special financial products. 322*0e209d39SAndroid Build Coastguard Worker * A fund code is a monetary resource associated with a currency. 323*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.2 324*0e209d39SAndroid Build Coastguard Worker */ 325*0e209d39SAndroid Build Coastguard Worker UCURR_UNCOMMON = 2, 326*0e209d39SAndroid Build Coastguard Worker /** 327*0e209d39SAndroid Build Coastguard Worker * Select only deprecated ISO-4217 codes. 328*0e209d39SAndroid Build Coastguard Worker * These codes are no longer in general public use. 329*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.2 330*0e209d39SAndroid Build Coastguard Worker */ 331*0e209d39SAndroid Build Coastguard Worker UCURR_DEPRECATED = 4, 332*0e209d39SAndroid Build Coastguard Worker /** 333*0e209d39SAndroid Build Coastguard Worker * Select only non-deprecated ISO-4217 codes. 334*0e209d39SAndroid Build Coastguard Worker * These codes are in general public use. 335*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.2 336*0e209d39SAndroid Build Coastguard Worker */ 337*0e209d39SAndroid Build Coastguard Worker UCURR_NON_DEPRECATED = 8 338*0e209d39SAndroid Build Coastguard Worker } UCurrCurrencyType; 339*0e209d39SAndroid Build Coastguard Worker 340*0e209d39SAndroid Build Coastguard Worker /** 341*0e209d39SAndroid Build Coastguard Worker * Provides a UEnumeration object for listing ISO-4217 codes. 342*0e209d39SAndroid Build Coastguard Worker * @param currType You can use one of several UCurrCurrencyType values for this 343*0e209d39SAndroid Build Coastguard Worker * variable. You can also | (or) them together to get a specific list of 344*0e209d39SAndroid Build Coastguard Worker * currencies. Most people will want to use the (UCURR_COMMON|UCURR_NON_DEPRECATED) value to 345*0e209d39SAndroid Build Coastguard Worker * get a list of current currencies. 346*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Error code 347*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.2 348*0e209d39SAndroid Build Coastguard Worker */ 349*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration * U_EXPORT2 350*0e209d39SAndroid Build Coastguard Worker ucurr_openISOCurrencies(uint32_t currType, UErrorCode *pErrorCode); 351*0e209d39SAndroid Build Coastguard Worker 352*0e209d39SAndroid Build Coastguard Worker /** 353*0e209d39SAndroid Build Coastguard Worker * Queries if the given ISO 4217 3-letter code is available on the specified date range. 354*0e209d39SAndroid Build Coastguard Worker * 355*0e209d39SAndroid Build Coastguard Worker * Note: For checking availability of a currency on a specific date, specify the date on both 'from' and 'to' 356*0e209d39SAndroid Build Coastguard Worker * 357*0e209d39SAndroid Build Coastguard Worker * When 'from' is U_DATE_MIN and 'to' is U_DATE_MAX, this method checks if the specified currency is available any time. 358*0e209d39SAndroid Build Coastguard Worker * If 'from' and 'to' are same UDate value, this method checks if the specified currency is available on that date. 359*0e209d39SAndroid Build Coastguard Worker * 360*0e209d39SAndroid Build Coastguard Worker * @param isoCode 361*0e209d39SAndroid Build Coastguard Worker * The ISO 4217 3-letter code. 362*0e209d39SAndroid Build Coastguard Worker * 363*0e209d39SAndroid Build Coastguard Worker * @param from 364*0e209d39SAndroid Build Coastguard Worker * The lower bound of the date range, inclusive. When 'from' is U_DATE_MIN, check the availability 365*0e209d39SAndroid Build Coastguard Worker * of the currency any date before 'to' 366*0e209d39SAndroid Build Coastguard Worker * 367*0e209d39SAndroid Build Coastguard Worker * @param to 368*0e209d39SAndroid Build Coastguard Worker * The upper bound of the date range, inclusive. When 'to' is U_DATE_MAX, check the availability of 369*0e209d39SAndroid Build Coastguard Worker * the currency any date after 'from' 370*0e209d39SAndroid Build Coastguard Worker * 371*0e209d39SAndroid Build Coastguard Worker * @param errorCode 372*0e209d39SAndroid Build Coastguard Worker * ICU error code 373*0e209d39SAndroid Build Coastguard Worker * 374*0e209d39SAndroid Build Coastguard Worker * @return true if the given ISO 4217 3-letter code is supported on the specified date range. 375*0e209d39SAndroid Build Coastguard Worker * 376*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.8 377*0e209d39SAndroid Build Coastguard Worker */ 378*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 379*0e209d39SAndroid Build Coastguard Worker ucurr_isAvailable(const UChar* isoCode, 380*0e209d39SAndroid Build Coastguard Worker UDate from, 381*0e209d39SAndroid Build Coastguard Worker UDate to, 382*0e209d39SAndroid Build Coastguard Worker UErrorCode* errorCode); 383*0e209d39SAndroid Build Coastguard Worker 384*0e209d39SAndroid Build Coastguard Worker /** 385*0e209d39SAndroid Build Coastguard Worker * Finds the number of valid currency codes for the 386*0e209d39SAndroid Build Coastguard Worker * given locale and date. 387*0e209d39SAndroid Build Coastguard Worker * @param locale the locale for which to retrieve the 388*0e209d39SAndroid Build Coastguard Worker * currency count. 389*0e209d39SAndroid Build Coastguard Worker * @param date the date for which to retrieve the 390*0e209d39SAndroid Build Coastguard Worker * currency count for the given locale. 391*0e209d39SAndroid Build Coastguard Worker * @param ec error code 392*0e209d39SAndroid Build Coastguard Worker * @return the number of currency codes for the 393*0e209d39SAndroid Build Coastguard Worker * given locale and date. If 0, currency 394*0e209d39SAndroid Build Coastguard Worker * codes couldn't be found for the input 395*0e209d39SAndroid Build Coastguard Worker * values are invalid. 396*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 397*0e209d39SAndroid Build Coastguard Worker */ 398*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 399*0e209d39SAndroid Build Coastguard Worker ucurr_countCurrencies(const char* locale, 400*0e209d39SAndroid Build Coastguard Worker UDate date, 401*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec); 402*0e209d39SAndroid Build Coastguard Worker 403*0e209d39SAndroid Build Coastguard Worker /** 404*0e209d39SAndroid Build Coastguard Worker * Finds a currency code for the given locale and date 405*0e209d39SAndroid Build Coastguard Worker * @param locale the locale for which to retrieve a currency code. 406*0e209d39SAndroid Build Coastguard Worker * Currency can be specified by the "currency" keyword 407*0e209d39SAndroid Build Coastguard Worker * in which case it overrides the default currency code 408*0e209d39SAndroid Build Coastguard Worker * @param date the date for which to retrieve a currency code for 409*0e209d39SAndroid Build Coastguard Worker * the given locale. 410*0e209d39SAndroid Build Coastguard Worker * @param index the index within the available list of currency codes 411*0e209d39SAndroid Build Coastguard Worker * for the given locale on the given date. 412*0e209d39SAndroid Build Coastguard Worker * @param buff fill in buffer. Can be NULL for preflighting. 413*0e209d39SAndroid Build Coastguard Worker * @param buffCapacity capacity of the fill in buffer. Can be 0 for 414*0e209d39SAndroid Build Coastguard Worker * preflighting. If it is non-zero, the buff parameter 415*0e209d39SAndroid Build Coastguard Worker * must not be NULL. 416*0e209d39SAndroid Build Coastguard Worker * @param ec error code 417*0e209d39SAndroid Build Coastguard Worker * @return length of the currency string. It should always be 3. 418*0e209d39SAndroid Build Coastguard Worker * If 0, currency couldn't be found or the input values are 419*0e209d39SAndroid Build Coastguard Worker * invalid. 420*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.0 421*0e209d39SAndroid Build Coastguard Worker */ 422*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 423*0e209d39SAndroid Build Coastguard Worker ucurr_forLocaleAndDate(const char* locale, 424*0e209d39SAndroid Build Coastguard Worker UDate date, 425*0e209d39SAndroid Build Coastguard Worker int32_t index, 426*0e209d39SAndroid Build Coastguard Worker UChar* buff, 427*0e209d39SAndroid Build Coastguard Worker int32_t buffCapacity, 428*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec); 429*0e209d39SAndroid Build Coastguard Worker 430*0e209d39SAndroid Build Coastguard Worker /** 431*0e209d39SAndroid Build Coastguard Worker * Given a key and a locale, returns an array of string values in a preferred 432*0e209d39SAndroid Build Coastguard Worker * order that would make a difference. These are all and only those values where 433*0e209d39SAndroid Build Coastguard Worker * the open (creation) of the service with the locale formed from the input locale 434*0e209d39SAndroid Build Coastguard Worker * plus input keyword and that value has different behavior than creation with the 435*0e209d39SAndroid Build Coastguard Worker * input locale alone. 436*0e209d39SAndroid Build Coastguard Worker * @param key one of the keys supported by this service. For now, only 437*0e209d39SAndroid Build Coastguard Worker * "currency" is supported. 438*0e209d39SAndroid Build Coastguard Worker * @param locale the locale 439*0e209d39SAndroid Build Coastguard Worker * @param commonlyUsed if set to true it will return only commonly used values 440*0e209d39SAndroid Build Coastguard Worker * with the given locale in preferred order. Otherwise, 441*0e209d39SAndroid Build Coastguard Worker * it will return all the available values for the locale. 442*0e209d39SAndroid Build Coastguard Worker * @param status error status 443*0e209d39SAndroid Build Coastguard Worker * @return a string enumeration over keyword values for the given key and the locale. 444*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.2 445*0e209d39SAndroid Build Coastguard Worker */ 446*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2 447*0e209d39SAndroid Build Coastguard Worker ucurr_getKeywordValuesForLocale(const char* key, 448*0e209d39SAndroid Build Coastguard Worker const char* locale, 449*0e209d39SAndroid Build Coastguard Worker UBool commonlyUsed, 450*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 451*0e209d39SAndroid Build Coastguard Worker 452*0e209d39SAndroid Build Coastguard Worker /** 453*0e209d39SAndroid Build Coastguard Worker * Returns the ISO 4217 numeric code for the currency. 454*0e209d39SAndroid Build Coastguard Worker * <p>Note: If the ISO 4217 numeric code is not assigned for the currency or 455*0e209d39SAndroid Build Coastguard Worker * the currency is unknown, this function returns 0. 456*0e209d39SAndroid Build Coastguard Worker * 457*0e209d39SAndroid Build Coastguard Worker * @param currency null-terminated 3-letter ISO 4217 code 458*0e209d39SAndroid Build Coastguard Worker * @return The ISO 4217 numeric code of the currency 459*0e209d39SAndroid Build Coastguard Worker * @stable ICU 49 460*0e209d39SAndroid Build Coastguard Worker */ 461*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 462*0e209d39SAndroid Build Coastguard Worker ucurr_getNumericCode(const UChar* currency); 463*0e209d39SAndroid Build Coastguard Worker 464*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_FORMATTING */ 465*0e209d39SAndroid Build Coastguard Worker 466*0e209d39SAndroid Build Coastguard Worker #endif 467