xref: /aosp_15_r20/external/icu/libicu/cts_headers/ucurrimp.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
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 
10*0e209d39SAndroid Build Coastguard Worker #ifndef _UCURR_IMP_H_
11*0e209d39SAndroid Build Coastguard Worker #define _UCURR_IMP_H_
12*0e209d39SAndroid Build Coastguard Worker 
13*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h"
14*0e209d39SAndroid Build Coastguard Worker #include "unicode/unistr.h"
15*0e209d39SAndroid Build Coastguard Worker #include "unicode/parsepos.h"
16*0e209d39SAndroid Build Coastguard Worker #include "unicode/uniset.h"
17*0e209d39SAndroid Build Coastguard Worker 
18*0e209d39SAndroid Build Coastguard Worker /**
19*0e209d39SAndroid Build Coastguard Worker  * Internal method.  Given a currency ISO code and a locale, return
20*0e209d39SAndroid Build Coastguard Worker  * the "static" currency name.  This is usually the same as the
21*0e209d39SAndroid Build Coastguard Worker  * UCURR_SYMBOL_NAME, but if the latter is a choice format, then the
22*0e209d39SAndroid Build Coastguard Worker  * format is applied to the number 2.0 (to yield the more common
23*0e209d39SAndroid Build Coastguard Worker  * plural) to return a static name.
24*0e209d39SAndroid Build Coastguard Worker  *
25*0e209d39SAndroid Build Coastguard Worker  * This is used for backward compatibility with old currency logic in
26*0e209d39SAndroid Build Coastguard Worker  * DecimalFormat and DecimalFormatSymbols.
27*0e209d39SAndroid Build Coastguard Worker  */
28*0e209d39SAndroid Build Coastguard Worker U_CAPI void
29*0e209d39SAndroid Build Coastguard Worker uprv_getStaticCurrencyName(const UChar* iso, const char* loc,
30*0e209d39SAndroid Build Coastguard Worker                            icu::UnicodeString& result, UErrorCode& ec);
31*0e209d39SAndroid Build Coastguard Worker 
32*0e209d39SAndroid Build Coastguard Worker /**
33*0e209d39SAndroid Build Coastguard Worker  * Attempt to parse the given string as a currency, either as a
34*0e209d39SAndroid Build Coastguard Worker  * display name in the given locale, or as a 3-letter ISO 4217
35*0e209d39SAndroid Build Coastguard Worker  * code.  If multiple display names match, then the longest one is
36*0e209d39SAndroid Build Coastguard Worker  * selected.  If both a display name and a 3-letter ISO code
37*0e209d39SAndroid Build Coastguard Worker  * match, then the display name is preferred, unless it's length
38*0e209d39SAndroid Build Coastguard Worker  * is less than 3.
39*0e209d39SAndroid Build Coastguard Worker  *
40*0e209d39SAndroid Build Coastguard Worker  * The parameters must not be NULL.
41*0e209d39SAndroid Build Coastguard Worker  *
42*0e209d39SAndroid Build Coastguard Worker  * @param locale the locale of the display names to match
43*0e209d39SAndroid Build Coastguard Worker  * @param text the text to parse
44*0e209d39SAndroid Build Coastguard Worker  * @param pos input-output position; on input, the position within
45*0e209d39SAndroid Build Coastguard Worker  * text to match; must have 0 <= pos.getIndex() < text.length();
46*0e209d39SAndroid Build Coastguard Worker  * on output, the position after the last matched character. If
47*0e209d39SAndroid Build Coastguard Worker  * the parse fails, the position in unchanged upon output.
48*0e209d39SAndroid Build Coastguard Worker  * @param type currency type to parse against, LONG_NAME only or not
49*0e209d39SAndroid Build Coastguard Worker  * @param partialMatchLen The length of the longest matching prefix;
50*0e209d39SAndroid Build Coastguard Worker  * this may be nonzero even if no full currency was matched.
51*0e209d39SAndroid Build Coastguard Worker  * @return the ISO 4217 code, as a string, of the best match, or
52*0e209d39SAndroid Build Coastguard Worker  * null if there is no match
53*0e209d39SAndroid Build Coastguard Worker  *
54*0e209d39SAndroid Build Coastguard Worker  * @internal
55*0e209d39SAndroid Build Coastguard Worker  */
56*0e209d39SAndroid Build Coastguard Worker U_CAPI void
57*0e209d39SAndroid Build Coastguard Worker uprv_parseCurrency(const char* locale,
58*0e209d39SAndroid Build Coastguard Worker                    const icu::UnicodeString& text,
59*0e209d39SAndroid Build Coastguard Worker                    icu::ParsePosition& pos,
60*0e209d39SAndroid Build Coastguard Worker                    int8_t type,
61*0e209d39SAndroid Build Coastguard Worker                    int32_t* partialMatchLen,
62*0e209d39SAndroid Build Coastguard Worker                    UChar* result,
63*0e209d39SAndroid Build Coastguard Worker                    UErrorCode& ec);
64*0e209d39SAndroid Build Coastguard Worker 
65*0e209d39SAndroid Build Coastguard Worker /**
66*0e209d39SAndroid Build Coastguard Worker  * Puts all possible first-characters of a currency into the
67*0e209d39SAndroid Build Coastguard Worker  * specified UnicodeSet.
68*0e209d39SAndroid Build Coastguard Worker  *
69*0e209d39SAndroid Build Coastguard Worker  * @param locale the locale of the display names of interest
70*0e209d39SAndroid Build Coastguard Worker  * @param result the UnicodeSet to which to add the starting characters
71*0e209d39SAndroid Build Coastguard Worker  */
72*0e209d39SAndroid Build Coastguard Worker void uprv_currencyLeads(const char* locale, icu::UnicodeSet& result, UErrorCode& ec);
73*0e209d39SAndroid Build Coastguard Worker 
74*0e209d39SAndroid Build Coastguard Worker 
75*0e209d39SAndroid Build Coastguard Worker 
76*0e209d39SAndroid Build Coastguard Worker #endif /* #ifndef _UCURR_IMP_H_ */
77*0e209d39SAndroid Build Coastguard Worker 
78*0e209d39SAndroid Build Coastguard Worker //eof
79