intl/icu/source/i18n/unicode/ucurr.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 **********************************************************************
michael@0 3 * Copyright (c) 2002-2013, International Business Machines
michael@0 4 * Corporation and others. All Rights Reserved.
michael@0 5 **********************************************************************
michael@0 6 */
michael@0 7 #ifndef _UCURR_H_
michael@0 8 #define _UCURR_H_
michael@0 9
michael@0 10 #include "unicode/utypes.h"
michael@0 11 #include "unicode/uenum.h"
michael@0 12
michael@0 13 /**
michael@0 14 * \file
michael@0 15 * \brief C API: Encapsulates information about a currency.
michael@0 16 */
michael@0 17
michael@0 18 #if !UCONFIG_NO_FORMATTING
michael@0 19
michael@0 20 /**
michael@0 21 * The ucurr API encapsulates information about a currency, as defined by
michael@0 22 * ISO 4217. A currency is represented by a 3-character string
michael@0 23 * containing its ISO 4217 code. This API can return various data
michael@0 24 * necessary the proper display of a currency:
michael@0 25 *
michael@0 26 * <ul><li>A display symbol, for a specific locale
michael@0 27 * <li>The number of fraction digits to display
michael@0 28 * <li>A rounding increment
michael@0 29 * </ul>
michael@0 30 *
michael@0 31 * The <tt>DecimalFormat</tt> class uses these data to display
michael@0 32 * currencies.
michael@0 33 * @author Alan Liu
michael@0 34 * @since ICU 2.2
michael@0 35 */
michael@0 36
michael@0 37 /**
michael@0 38 * Finds a currency code for the given locale.
michael@0 39 * @param locale the locale for which to retrieve a currency code.
michael@0 40 * Currency can be specified by the "currency" keyword
michael@0 41 * in which case it overrides the default currency code
michael@0 42 * @param buff fill in buffer. Can be NULL for preflighting.
michael@0 43 * @param buffCapacity capacity of the fill in buffer. Can be 0 for
michael@0 44 * preflighting. If it is non-zero, the buff parameter
michael@0 45 * must not be NULL.
michael@0 46 * @param ec error code
michael@0 47 * @return length of the currency string. It should always be 3. If 0,
michael@0 48 * currency couldn't be found or the input values are
michael@0 49 * invalid.
michael@0 50 * @stable ICU 2.8
michael@0 51 */
michael@0 52 U_STABLE int32_t U_EXPORT2
michael@0 53 ucurr_forLocale(const char* locale,
michael@0 54 UChar* buff,
michael@0 55 int32_t buffCapacity,
michael@0 56 UErrorCode* ec);
michael@0 57
michael@0 58 /**
michael@0 59 * Selector constants for ucurr_getName().
michael@0 60 *
michael@0 61 * @see ucurr_getName
michael@0 62 * @stable ICU 2.6
michael@0 63 */
michael@0 64 typedef enum UCurrNameStyle {
michael@0 65 /**
michael@0 66 * Selector for ucurr_getName indicating a symbolic name for a
michael@0 67 * currency, such as "$" for USD.
michael@0 68 * @stable ICU 2.6
michael@0 69 */
michael@0 70 UCURR_SYMBOL_NAME,
michael@0 71
michael@0 72 /**
michael@0 73 * Selector for ucurr_getName indicating the long name for a
michael@0 74 * currency, such as "US Dollar" for USD.
michael@0 75 * @stable ICU 2.6
michael@0 76 */
michael@0 77 UCURR_LONG_NAME
michael@0 78 } UCurrNameStyle;
michael@0 79
michael@0 80 #if !UCONFIG_NO_SERVICE
michael@0 81 /**
michael@0 82 * @stable ICU 2.6
michael@0 83 */
michael@0 84 typedef const void* UCurrRegistryKey;
michael@0 85
michael@0 86 /**
michael@0 87 * Register an (existing) ISO 4217 currency code for the given locale.
michael@0 88 * Only the country code and the two variants EURO and PRE_EURO are
michael@0 89 * recognized.
michael@0 90 * @param isoCode the three-letter ISO 4217 currency code
michael@0 91 * @param locale the locale for which to register this currency code
michael@0 92 * @param status the in/out status code
michael@0 93 * @return a registry key that can be used to unregister this currency code, or NULL
michael@0 94 * if there was an error.
michael@0 95 * @stable ICU 2.6
michael@0 96 */
michael@0 97 U_STABLE UCurrRegistryKey U_EXPORT2
michael@0 98 ucurr_register(const UChar* isoCode,
michael@0 99 const char* locale,
michael@0 100 UErrorCode* status);
michael@0 101 /**
michael@0 102 * Unregister the previously-registered currency definitions using the
michael@0 103 * URegistryKey returned from ucurr_register. Key becomes invalid after
michael@0 104 * a successful call and should not be used again. Any currency
michael@0 105 * that might have been hidden by the original ucurr_register call is
michael@0 106 * restored.
michael@0 107 * @param key the registry key returned by a previous call to ucurr_register
michael@0 108 * @param status the in/out status code, no special meanings are assigned
michael@0 109 * @return TRUE if the currency for this key was successfully unregistered
michael@0 110 * @stable ICU 2.6
michael@0 111 */
michael@0 112 U_STABLE UBool U_EXPORT2
michael@0 113 ucurr_unregister(UCurrRegistryKey key, UErrorCode* status);
michael@0 114 #endif /* UCONFIG_NO_SERVICE */
michael@0 115
michael@0 116 /**
michael@0 117 * Returns the display name for the given currency in the
michael@0 118 * given locale. For example, the display name for the USD
michael@0 119 * currency object in the en_US locale is "$".
michael@0 120 * @param currency null-terminated 3-letter ISO 4217 code
michael@0 121 * @param locale locale in which to display currency
michael@0 122 * @param nameStyle selector for which kind of name to return
michael@0 123 * @param isChoiceFormat fill-in set to TRUE if the returned value
michael@0 124 * is a ChoiceFormat pattern; otherwise it is a static string
michael@0 125 * @param len fill-in parameter to receive length of result
michael@0 126 * @param ec error code
michael@0 127 * @return pointer to display string of 'len' UChars. If the resource
michael@0 128 * data contains no entry for 'currency', then 'currency' itself is
michael@0 129 * returned. If *isChoiceFormat is TRUE, then the result is a
michael@0 130 * ChoiceFormat pattern. Otherwise it is a static string.
michael@0 131 * @stable ICU 2.6
michael@0 132 */
michael@0 133 U_STABLE const UChar* U_EXPORT2
michael@0 134 ucurr_getName(const UChar* currency,
michael@0 135 const char* locale,
michael@0 136 UCurrNameStyle nameStyle,
michael@0 137 UBool* isChoiceFormat,
michael@0 138 int32_t* len,
michael@0 139 UErrorCode* ec);
michael@0 140
michael@0 141 /**
michael@0 142 * Returns the plural name for the given currency in the
michael@0 143 * given locale. For example, the plural name for the USD
michael@0 144 * currency object in the en_US locale is "US dollar" or "US dollars".
michael@0 145 * @param currency null-terminated 3-letter ISO 4217 code
michael@0 146 * @param locale locale in which to display currency
michael@0 147 * @param isChoiceFormat fill-in set to TRUE if the returned value
michael@0 148 * is a ChoiceFormat pattern; otherwise it is a static string
michael@0 149 * @param pluralCount plural count
michael@0 150 * @param len fill-in parameter to receive length of result
michael@0 151 * @param ec error code
michael@0 152 * @return pointer to display string of 'len' UChars. If the resource
michael@0 153 * data contains no entry for 'currency', then 'currency' itself is
michael@0 154 * returned.
michael@0 155 * @stable ICU 4.2
michael@0 156 */
michael@0 157 U_STABLE const UChar* U_EXPORT2
michael@0 158 ucurr_getPluralName(const UChar* currency,
michael@0 159 const char* locale,
michael@0 160 UBool* isChoiceFormat,
michael@0 161 const char* pluralCount,
michael@0 162 int32_t* len,
michael@0 163 UErrorCode* ec);
michael@0 164
michael@0 165 /**
michael@0 166 * Returns the number of the number of fraction digits that should
michael@0 167 * be displayed for the given currency.
michael@0 168 * @param currency null-terminated 3-letter ISO 4217 code
michael@0 169 * @param ec input-output error code
michael@0 170 * @return a non-negative number of fraction digits to be
michael@0 171 * displayed, or 0 if there is an error
michael@0 172 * @stable ICU 3.0
michael@0 173 */
michael@0 174 U_STABLE int32_t U_EXPORT2
michael@0 175 ucurr_getDefaultFractionDigits(const UChar* currency,
michael@0 176 UErrorCode* ec);
michael@0 177
michael@0 178 /**
michael@0 179 * Returns the rounding increment for the given currency, or 0.0 if no
michael@0 180 * rounding is done by the currency.
michael@0 181 * @param currency null-terminated 3-letter ISO 4217 code
michael@0 182 * @param ec input-output error code
michael@0 183 * @return the non-negative rounding increment, or 0.0 if none,
michael@0 184 * or 0.0 if there is an error
michael@0 185 * @stable ICU 3.0
michael@0 186 */
michael@0 187 U_STABLE double U_EXPORT2
michael@0 188 ucurr_getRoundingIncrement(const UChar* currency,
michael@0 189 UErrorCode* ec);
michael@0 190
michael@0 191 /**
michael@0 192 * Selector constants for ucurr_openCurrencies().
michael@0 193 *
michael@0 194 * @see ucurr_openCurrencies
michael@0 195 * @stable ICU 3.2
michael@0 196 */
michael@0 197 typedef enum UCurrCurrencyType {
michael@0 198 /**
michael@0 199 * Select all ISO-4217 currency codes.
michael@0 200 * @stable ICU 3.2
michael@0 201 */
michael@0 202 UCURR_ALL = INT32_MAX,
michael@0 203 /**
michael@0 204 * Select only ISO-4217 commonly used currency codes.
michael@0 205 * These currencies can be found in common use, and they usually have
michael@0 206 * bank notes or coins associated with the currency code.
michael@0 207 * This does not include fund codes, precious metals and other
michael@0 208 * various ISO-4217 codes limited to special financial products.
michael@0 209 * @stable ICU 3.2
michael@0 210 */
michael@0 211 UCURR_COMMON = 1,
michael@0 212 /**
michael@0 213 * Select ISO-4217 uncommon currency codes.
michael@0 214 * These codes respresent fund codes, precious metals and other
michael@0 215 * various ISO-4217 codes limited to special financial products.
michael@0 216 * A fund code is a monetary resource associated with a currency.
michael@0 217 * @stable ICU 3.2
michael@0 218 */
michael@0 219 UCURR_UNCOMMON = 2,
michael@0 220 /**
michael@0 221 * Select only deprecated ISO-4217 codes.
michael@0 222 * These codes are no longer in general public use.
michael@0 223 * @stable ICU 3.2
michael@0 224 */
michael@0 225 UCURR_DEPRECATED = 4,
michael@0 226 /**
michael@0 227 * Select only non-deprecated ISO-4217 codes.
michael@0 228 * These codes are in general public use.
michael@0 229 * @stable ICU 3.2
michael@0 230 */
michael@0 231 UCURR_NON_DEPRECATED = 8
michael@0 232 } UCurrCurrencyType;
michael@0 233
michael@0 234 /**
michael@0 235 * Provides a UEnumeration object for listing ISO-4217 codes.
michael@0 236 * @param currType You can use one of several UCurrCurrencyType values for this
michael@0 237 * variable. You can also | (or) them together to get a specific list of
michael@0 238 * currencies. Most people will want to use the (UCURR_CURRENCY|UCURR_NON_DEPRECATED) value to
michael@0 239 * get a list of current currencies.
michael@0 240 * @param pErrorCode Error code
michael@0 241 * @stable ICU 3.2
michael@0 242 */
michael@0 243 U_STABLE UEnumeration * U_EXPORT2
michael@0 244 ucurr_openISOCurrencies(uint32_t currType, UErrorCode *pErrorCode);
michael@0 245
michael@0 246 /**
michael@0 247 * Queries if the given ISO 4217 3-letter code is available on the specified date range.
michael@0 248 *
michael@0 249 * Note: For checking availability of a currency on a specific date, specify the date on both 'from' and 'to'
michael@0 250 *
michael@0 251 * When 'from' is U_DATE_MIN and 'to' is U_DATE_MAX, this method checks if the specified currency is available any time.
michael@0 252 * If 'from' and 'to' are same UDate value, this method checks if the specified currency is available on that date.
michael@0 253 *
michael@0 254 * @param isoCode
michael@0 255 * The ISO 4217 3-letter code.
michael@0 256 *
michael@0 257 * @param from
michael@0 258 * The lower bound of the date range, inclusive. When 'from' is U_DATE_MIN, check the availability
michael@0 259 * of the currency any date before 'to'
michael@0 260 *
michael@0 261 * @param to
michael@0 262 * The upper bound of the date range, inclusive. When 'to' is U_DATE_MAX, check the availability of
michael@0 263 * the currency any date after 'from'
michael@0 264 *
michael@0 265 * @param errorCode
michael@0 266 * ICU error code
michael@0 267 *
michael@0 268 * @return TRUE if the given ISO 4217 3-letter code is supported on the specified date range.
michael@0 269 *
michael@0 270 * @stable ICU 4.8
michael@0 271 */
michael@0 272 U_STABLE UBool U_EXPORT2
michael@0 273 ucurr_isAvailable(const UChar* isoCode,
michael@0 274 UDate from,
michael@0 275 UDate to,
michael@0 276 UErrorCode* errorCode);
michael@0 277
michael@0 278 /**
michael@0 279 * Finds the number of valid currency codes for the
michael@0 280 * given locale and date.
michael@0 281 * @param locale the locale for which to retrieve the
michael@0 282 * currency count.
michael@0 283 * @param date the date for which to retrieve the
michael@0 284 * currency count for the given locale.
michael@0 285 * @param ec error code
michael@0 286 * @return the number of currency codes for the
michael@0 287 * given locale and date. If 0, currency
michael@0 288 * codes couldn't be found for the input
michael@0 289 * values are invalid.
michael@0 290 * @stable ICU 4.0
michael@0 291 */
michael@0 292 U_STABLE int32_t U_EXPORT2
michael@0 293 ucurr_countCurrencies(const char* locale,
michael@0 294 UDate date,
michael@0 295 UErrorCode* ec);
michael@0 296
michael@0 297 /**
michael@0 298 * Finds a currency code for the given locale and date
michael@0 299 * @param locale the locale for which to retrieve a currency code.
michael@0 300 * Currency can be specified by the "currency" keyword
michael@0 301 * in which case it overrides the default currency code
michael@0 302 * @param date the date for which to retrieve a currency code for
michael@0 303 * the given locale.
michael@0 304 * @param index the index within the available list of currency codes
michael@0 305 * for the given locale on the given date.
michael@0 306 * @param buff fill in buffer. Can be NULL for preflighting.
michael@0 307 * @param buffCapacity capacity of the fill in buffer. Can be 0 for
michael@0 308 * preflighting. If it is non-zero, the buff parameter
michael@0 309 * must not be NULL.
michael@0 310 * @param ec error code
michael@0 311 * @return length of the currency string. It should always be 3.
michael@0 312 * If 0, currency couldn't be found or the input values are
michael@0 313 * invalid.
michael@0 314 * @stable ICU 4.0
michael@0 315 */
michael@0 316 U_STABLE int32_t U_EXPORT2
michael@0 317 ucurr_forLocaleAndDate(const char* locale,
michael@0 318 UDate date,
michael@0 319 int32_t index,
michael@0 320 UChar* buff,
michael@0 321 int32_t buffCapacity,
michael@0 322 UErrorCode* ec);
michael@0 323
michael@0 324 /**
michael@0 325 * Given a key and a locale, returns an array of string values in a preferred
michael@0 326 * order that would make a difference. These are all and only those values where
michael@0 327 * the open (creation) of the service with the locale formed from the input locale
michael@0 328 * plus input keyword and that value has different behavior than creation with the
michael@0 329 * input locale alone.
michael@0 330 * @param key one of the keys supported by this service. For now, only
michael@0 331 * "currency" is supported.
michael@0 332 * @param locale the locale
michael@0 333 * @param commonlyUsed if set to true it will return only commonly used values
michael@0 334 * with the given locale in preferred order. Otherwise,
michael@0 335 * it will return all the available values for the locale.
michael@0 336 * @param status error status
michael@0 337 * @return a string enumeration over keyword values for the given key and the locale.
michael@0 338 * @stable ICU 4.2
michael@0 339 */
michael@0 340 U_STABLE UEnumeration* U_EXPORT2
michael@0 341 ucurr_getKeywordValuesForLocale(const char* key,
michael@0 342 const char* locale,
michael@0 343 UBool commonlyUsed,
michael@0 344 UErrorCode* status);
michael@0 345
michael@0 346 /**
michael@0 347 * Returns the ISO 4217 numeric code for the currency.
michael@0 348 * <p>Note: If the ISO 4217 numeric code is not assigned for the currency or
michael@0 349 * the currency is unknown, this function returns 0.
michael@0 350 *
michael@0 351 * @param currency null-terminated 3-letter ISO 4217 code
michael@0 352 * @return The ISO 4217 numeric code of the currency
michael@0 353 * @stable ICU 49
michael@0 354 */
michael@0 355 U_STABLE int32_t U_EXPORT2
michael@0 356 ucurr_getNumericCode(const UChar* currency);
michael@0 357
michael@0 358 #endif /* #if !UCONFIG_NO_FORMATTING */
michael@0 359
michael@0 360 #endif

mercurial