ucurrimp.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. **********************************************************************
  5. * Copyright (c) 2002-2016, International Business Machines
  6. * Corporation and others. All Rights Reserved.
  7. **********************************************************************
  8. */
  9. #ifndef _UCURR_IMP_H_
  10. #define _UCURR_IMP_H_
  11. #include "unicode/utypes.h"
  12. #include "unicode/unistr.h"
  13. #include "unicode/parsepos.h"
  14. #include "unicode/uniset.h"
  15. /**
  16. * Internal method. Given a currency ISO code and a locale, return
  17. * the "static" currency name. This is usually the same as the
  18. * UCURR_SYMBOL_NAME, but if the latter is a choice format, then the
  19. * format is applied to the number 2.0 (to yield the more common
  20. * plural) to return a static name.
  21. *
  22. * This is used for backward compatibility with old currency logic in
  23. * DecimalFormat and DecimalFormatSymbols.
  24. */
  25. U_CAPI void
  26. uprv_getStaticCurrencyName(const UChar* iso, const char* loc,
  27. icu::UnicodeString& result, UErrorCode& ec);
  28. /**
  29. * Attempt to parse the given string as a currency, either as a
  30. * display name in the given locale, or as a 3-letter ISO 4217
  31. * code. If multiple display names match, then the longest one is
  32. * selected. If both a display name and a 3-letter ISO code
  33. * match, then the display name is preferred, unless it's length
  34. * is less than 3.
  35. *
  36. * The parameters must not be NULL.
  37. *
  38. * @param locale the locale of the display names to match
  39. * @param text the text to parse
  40. * @param pos input-output position; on input, the position within
  41. * text to match; must have 0 <= pos.getIndex() < text.length();
  42. * on output, the position after the last matched character. If
  43. * the parse fails, the position in unchanged upon output.
  44. * @param type currency type to parse against, LONG_NAME only or not
  45. * @param partialMatchLen The length of the longest matching prefix;
  46. * this may be nonzero even if no full currency was matched.
  47. * @return the ISO 4217 code, as a string, of the best match, or
  48. * null if there is no match
  49. *
  50. * @internal
  51. */
  52. U_CAPI void
  53. uprv_parseCurrency(const char* locale,
  54. const icu::UnicodeString& text,
  55. icu::ParsePosition& pos,
  56. int8_t type,
  57. int32_t* partialMatchLen,
  58. UChar* result,
  59. UErrorCode& ec);
  60. /**
  61. * Puts all possible first-characters of a currency into the
  62. * specified UnicodeSet.
  63. *
  64. * @param locale the locale of the display names of interest
  65. * @param result the UnicodeSet to which to add the starting characters
  66. */
  67. void uprv_currencyLeads(const char* locale, icu::UnicodeSet& result, UErrorCode& ec);
  68. #endif /* #ifndef _UCURR_IMP_H_ */
  69. //eof