1*0e209d39SAndroid Build Coastguard Worker // © 2018 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 #ifndef __UNUMBERFORMATTER_H__ 5*0e209d39SAndroid Build Coastguard Worker #define __UNUMBERFORMATTER_H__ 6*0e209d39SAndroid Build Coastguard Worker 7*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 8*0e209d39SAndroid Build Coastguard Worker 9*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING 10*0e209d39SAndroid Build Coastguard Worker 11*0e209d39SAndroid Build Coastguard Worker #include "unicode/parseerr.h" 12*0e209d39SAndroid Build Coastguard Worker #include "unicode/unumberoptions.h" 13*0e209d39SAndroid Build Coastguard Worker #include "unicode/uformattednumber.h" 14*0e209d39SAndroid Build Coastguard Worker 15*0e209d39SAndroid Build Coastguard Worker 16*0e209d39SAndroid Build Coastguard Worker /** 17*0e209d39SAndroid Build Coastguard Worker * \file 18*0e209d39SAndroid Build Coastguard Worker * \brief C API: Localized number formatting; not recommended for C++. 19*0e209d39SAndroid Build Coastguard Worker * 20*0e209d39SAndroid Build Coastguard Worker * This is the C-compatible version of the NumberFormatter API introduced in ICU 60. C++ users should 21*0e209d39SAndroid Build Coastguard Worker * include unicode/numberformatter.h and use the proper C++ APIs. 22*0e209d39SAndroid Build Coastguard Worker * 23*0e209d39SAndroid Build Coastguard Worker * The C API accepts a number skeleton string for specifying the settings for formatting, which covers a 24*0e209d39SAndroid Build Coastguard Worker * very large subset of all possible number formatting features. For more information on number skeleton 25*0e209d39SAndroid Build Coastguard Worker * strings, see unicode/numberformatter.h. 26*0e209d39SAndroid Build Coastguard Worker * 27*0e209d39SAndroid Build Coastguard Worker * When using UNumberFormatter, which is treated as immutable, the results are exported to a mutable 28*0e209d39SAndroid Build Coastguard Worker * UFormattedNumber object, which you subsequently use for populating your string buffer or iterating over 29*0e209d39SAndroid Build Coastguard Worker * the fields. 30*0e209d39SAndroid Build Coastguard Worker * 31*0e209d39SAndroid Build Coastguard Worker * Example code: 32*0e209d39SAndroid Build Coastguard Worker * <pre> 33*0e209d39SAndroid Build Coastguard Worker * // Setup: 34*0e209d39SAndroid Build Coastguard Worker * UErrorCode ec = U_ZERO_ERROR; 35*0e209d39SAndroid Build Coastguard Worker * UNumberFormatter* uformatter = unumf_openForSkeletonAndLocale(u"precision-integer", -1, "en", &ec); 36*0e209d39SAndroid Build Coastguard Worker * UFormattedNumber* uresult = unumf_openResult(&ec); 37*0e209d39SAndroid Build Coastguard Worker * if (U_FAILURE(ec)) { return; } 38*0e209d39SAndroid Build Coastguard Worker * 39*0e209d39SAndroid Build Coastguard Worker * // Format a double: 40*0e209d39SAndroid Build Coastguard Worker * unumf_formatDouble(uformatter, 5142.3, uresult, &ec); 41*0e209d39SAndroid Build Coastguard Worker * if (U_FAILURE(ec)) { return; } 42*0e209d39SAndroid Build Coastguard Worker * 43*0e209d39SAndroid Build Coastguard Worker * // Export the string to a malloc'd buffer: 44*0e209d39SAndroid Build Coastguard Worker * int32_t len = unumf_resultToString(uresult, NULL, 0, &ec); 45*0e209d39SAndroid Build Coastguard Worker * // at this point, ec == U_BUFFER_OVERFLOW_ERROR 46*0e209d39SAndroid Build Coastguard Worker * ec = U_ZERO_ERROR; 47*0e209d39SAndroid Build Coastguard Worker * UChar* buffer = (UChar*) malloc((len+1)*sizeof(UChar)); 48*0e209d39SAndroid Build Coastguard Worker * unumf_resultToString(uresult, buffer, len+1, &ec); 49*0e209d39SAndroid Build Coastguard Worker * if (U_FAILURE(ec)) { return; } 50*0e209d39SAndroid Build Coastguard Worker * // buffer should equal "5,142" 51*0e209d39SAndroid Build Coastguard Worker * 52*0e209d39SAndroid Build Coastguard Worker * // Cleanup: 53*0e209d39SAndroid Build Coastguard Worker * unumf_close(uformatter); 54*0e209d39SAndroid Build Coastguard Worker * unumf_closeResult(uresult); 55*0e209d39SAndroid Build Coastguard Worker * free(buffer); 56*0e209d39SAndroid Build Coastguard Worker * </pre> 57*0e209d39SAndroid Build Coastguard Worker * 58*0e209d39SAndroid Build Coastguard Worker * If you are a C++ user linking against the C libraries, you can use the LocalPointer versions of these 59*0e209d39SAndroid Build Coastguard Worker * APIs. The following example uses LocalPointer with the decimal number and field position APIs: 60*0e209d39SAndroid Build Coastguard Worker * 61*0e209d39SAndroid Build Coastguard Worker * <pre> 62*0e209d39SAndroid Build Coastguard Worker * // Setup: 63*0e209d39SAndroid Build Coastguard Worker * LocalUNumberFormatterPointer uformatter(unumf_openForSkeletonAndLocale(u"percent", -1, "en", &ec)); 64*0e209d39SAndroid Build Coastguard Worker * LocalUFormattedNumberPointer uresult(unumf_openResult(&ec)); 65*0e209d39SAndroid Build Coastguard Worker * if (U_FAILURE(ec)) { return; } 66*0e209d39SAndroid Build Coastguard Worker * 67*0e209d39SAndroid Build Coastguard Worker * // Format a decimal number: 68*0e209d39SAndroid Build Coastguard Worker * unumf_formatDecimal(uformatter.getAlias(), "9.87E-3", -1, uresult.getAlias(), &ec); 69*0e209d39SAndroid Build Coastguard Worker * if (U_FAILURE(ec)) { return; } 70*0e209d39SAndroid Build Coastguard Worker * 71*0e209d39SAndroid Build Coastguard Worker * // Get the location of the percent sign: 72*0e209d39SAndroid Build Coastguard Worker * UFieldPosition ufpos = {UNUM_PERCENT_FIELD, 0, 0}; 73*0e209d39SAndroid Build Coastguard Worker * unumf_resultNextFieldPosition(uresult.getAlias(), &ufpos, &ec); 74*0e209d39SAndroid Build Coastguard Worker * // ufpos should contain beginIndex=7 and endIndex=8 since the string is "0.00987%" 75*0e209d39SAndroid Build Coastguard Worker * 76*0e209d39SAndroid Build Coastguard Worker * // No need to do any cleanup since we are using LocalPointer. 77*0e209d39SAndroid Build Coastguard Worker * </pre> 78*0e209d39SAndroid Build Coastguard Worker */ 79*0e209d39SAndroid Build Coastguard Worker 80*0e209d39SAndroid Build Coastguard Worker /** 81*0e209d39SAndroid Build Coastguard Worker * An enum declaring how to resolve conflicts between maximum fraction digits and maximum 82*0e209d39SAndroid Build Coastguard Worker * significant digits. 83*0e209d39SAndroid Build Coastguard Worker * 84*0e209d39SAndroid Build Coastguard Worker * There are two modes, RELAXED and STRICT: 85*0e209d39SAndroid Build Coastguard Worker * 86*0e209d39SAndroid Build Coastguard Worker * - RELAXED: Relax one of the two constraints (fraction digits or significant digits) in order 87*0e209d39SAndroid Build Coastguard Worker * to round the number to a higher level of precision. 88*0e209d39SAndroid Build Coastguard Worker * - STRICT: Enforce both constraints, resulting in the number being rounded to a lower 89*0e209d39SAndroid Build Coastguard Worker * level of precision. 90*0e209d39SAndroid Build Coastguard Worker * 91*0e209d39SAndroid Build Coastguard Worker * The default settings for compact notation rounding are Max-Fraction = 0 (round to the nearest 92*0e209d39SAndroid Build Coastguard Worker * integer), Max-Significant = 2 (round to 2 significant digits), and priority RELAXED (choose 93*0e209d39SAndroid Build Coastguard Worker * the constraint that results in more digits being displayed). 94*0e209d39SAndroid Build Coastguard Worker * 95*0e209d39SAndroid Build Coastguard Worker * Conflicting *minimum* fraction and significant digits are always resolved in the direction that 96*0e209d39SAndroid Build Coastguard Worker * results in more trailing zeros. 97*0e209d39SAndroid Build Coastguard Worker * 98*0e209d39SAndroid Build Coastguard Worker * Example 1: Consider the number 3.141, with various different settings: 99*0e209d39SAndroid Build Coastguard Worker * 100*0e209d39SAndroid Build Coastguard Worker * - Max-Fraction = 1: "3.1" 101*0e209d39SAndroid Build Coastguard Worker * - Max-Significant = 3: "3.14" 102*0e209d39SAndroid Build Coastguard Worker * 103*0e209d39SAndroid Build Coastguard Worker * The rounding priority determines how to resolve the conflict when both Max-Fraction and 104*0e209d39SAndroid Build Coastguard Worker * Max-Significant are set. With RELAXED, the less-strict setting (the one that causes more digits 105*0e209d39SAndroid Build Coastguard Worker * to be displayed) will be used; Max-Significant wins. With STRICT, the more-strict setting (the 106*0e209d39SAndroid Build Coastguard Worker * one that causes fewer digits to be displayed) will be used; Max-Fraction wins. 107*0e209d39SAndroid Build Coastguard Worker * 108*0e209d39SAndroid Build Coastguard Worker * Example 2: Consider the number 8317, with various different settings: 109*0e209d39SAndroid Build Coastguard Worker * 110*0e209d39SAndroid Build Coastguard Worker * - Max-Fraction = 1: "8317" 111*0e209d39SAndroid Build Coastguard Worker * - Max-Significant = 3: "8320" 112*0e209d39SAndroid Build Coastguard Worker * 113*0e209d39SAndroid Build Coastguard Worker * Here, RELAXED favors Max-Fraction and STRICT favors Max-Significant. Note that this larger 114*0e209d39SAndroid Build Coastguard Worker * number caused the two modes to favor the opposite result. 115*0e209d39SAndroid Build Coastguard Worker * 116*0e209d39SAndroid Build Coastguard Worker * @stable ICU 69 117*0e209d39SAndroid Build Coastguard Worker */ 118*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberRoundingPriority { 119*0e209d39SAndroid Build Coastguard Worker /** 120*0e209d39SAndroid Build Coastguard Worker * Favor greater precision by relaxing one of the rounding constraints. 121*0e209d39SAndroid Build Coastguard Worker * 122*0e209d39SAndroid Build Coastguard Worker * @stable ICU 69 123*0e209d39SAndroid Build Coastguard Worker */ 124*0e209d39SAndroid Build Coastguard Worker UNUM_ROUNDING_PRIORITY_RELAXED, 125*0e209d39SAndroid Build Coastguard Worker 126*0e209d39SAndroid Build Coastguard Worker /** 127*0e209d39SAndroid Build Coastguard Worker * Favor adherence to all rounding constraints by producing lower precision. 128*0e209d39SAndroid Build Coastguard Worker * 129*0e209d39SAndroid Build Coastguard Worker * @stable ICU 69 130*0e209d39SAndroid Build Coastguard Worker */ 131*0e209d39SAndroid Build Coastguard Worker UNUM_ROUNDING_PRIORITY_STRICT, 132*0e209d39SAndroid Build Coastguard Worker } UNumberRoundingPriority; 133*0e209d39SAndroid Build Coastguard Worker 134*0e209d39SAndroid Build Coastguard Worker /** 135*0e209d39SAndroid Build Coastguard Worker * An enum declaring how to render units, including currencies. Example outputs when formatting 123 USD and 123 136*0e209d39SAndroid Build Coastguard Worker * meters in <em>en-CA</em>: 137*0e209d39SAndroid Build Coastguard Worker * 138*0e209d39SAndroid Build Coastguard Worker * <p> 139*0e209d39SAndroid Build Coastguard Worker * <ul> 140*0e209d39SAndroid Build Coastguard Worker * <li>NARROW*: "$123.00" and "123 m" 141*0e209d39SAndroid Build Coastguard Worker * <li>SHORT: "US$ 123.00" and "123 m" 142*0e209d39SAndroid Build Coastguard Worker * <li>FULL_NAME: "123.00 US dollars" and "123 meters" 143*0e209d39SAndroid Build Coastguard Worker * <li>ISO_CODE: "USD 123.00" and undefined behavior 144*0e209d39SAndroid Build Coastguard Worker * <li>HIDDEN: "123.00" and "123" 145*0e209d39SAndroid Build Coastguard Worker * </ul> 146*0e209d39SAndroid Build Coastguard Worker * 147*0e209d39SAndroid Build Coastguard Worker * <p> 148*0e209d39SAndroid Build Coastguard Worker * This enum is similar to {@link UMeasureFormatWidth}. 149*0e209d39SAndroid Build Coastguard Worker * 150*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 151*0e209d39SAndroid Build Coastguard Worker */ 152*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberUnitWidth { 153*0e209d39SAndroid Build Coastguard Worker /** 154*0e209d39SAndroid Build Coastguard Worker * Print an abbreviated version of the unit name. Similar to SHORT, but always use the shortest available 155*0e209d39SAndroid Build Coastguard Worker * abbreviation or symbol. This option can be used when the context hints at the identity of the unit. For more 156*0e209d39SAndroid Build Coastguard Worker * information on the difference between NARROW and SHORT, see SHORT. 157*0e209d39SAndroid Build Coastguard Worker * 158*0e209d39SAndroid Build Coastguard Worker * <p> 159*0e209d39SAndroid Build Coastguard Worker * In CLDR, this option corresponds to the "Narrow" format for measure units and the "¤¤¤¤¤" placeholder for 160*0e209d39SAndroid Build Coastguard Worker * currencies. 161*0e209d39SAndroid Build Coastguard Worker * 162*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 163*0e209d39SAndroid Build Coastguard Worker */ 164*0e209d39SAndroid Build Coastguard Worker UNUM_UNIT_WIDTH_NARROW = 0, 165*0e209d39SAndroid Build Coastguard Worker 166*0e209d39SAndroid Build Coastguard Worker /** 167*0e209d39SAndroid Build Coastguard Worker * Print an abbreviated version of the unit name. Similar to NARROW, but use a slightly wider abbreviation or 168*0e209d39SAndroid Build Coastguard Worker * symbol when there may be ambiguity. This is the default behavior. 169*0e209d39SAndroid Build Coastguard Worker * 170*0e209d39SAndroid Build Coastguard Worker * <p> 171*0e209d39SAndroid Build Coastguard Worker * For example, in <em>es-US</em>, the SHORT form for Fahrenheit is "{0} °F", but the NARROW form is "{0}°", 172*0e209d39SAndroid Build Coastguard Worker * since Fahrenheit is the customary unit for temperature in that locale. 173*0e209d39SAndroid Build Coastguard Worker * 174*0e209d39SAndroid Build Coastguard Worker * <p> 175*0e209d39SAndroid Build Coastguard Worker * In CLDR, this option corresponds to the "Short" format for measure units and the "¤" placeholder for 176*0e209d39SAndroid Build Coastguard Worker * currencies. 177*0e209d39SAndroid Build Coastguard Worker * 178*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 179*0e209d39SAndroid Build Coastguard Worker */ 180*0e209d39SAndroid Build Coastguard Worker UNUM_UNIT_WIDTH_SHORT = 1, 181*0e209d39SAndroid Build Coastguard Worker 182*0e209d39SAndroid Build Coastguard Worker /** 183*0e209d39SAndroid Build Coastguard Worker * Print the full name of the unit, without any abbreviations. 184*0e209d39SAndroid Build Coastguard Worker * 185*0e209d39SAndroid Build Coastguard Worker * <p> 186*0e209d39SAndroid Build Coastguard Worker * In CLDR, this option corresponds to the default format for measure units and the "¤¤¤" placeholder for 187*0e209d39SAndroid Build Coastguard Worker * currencies. 188*0e209d39SAndroid Build Coastguard Worker * 189*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 190*0e209d39SAndroid Build Coastguard Worker */ 191*0e209d39SAndroid Build Coastguard Worker UNUM_UNIT_WIDTH_FULL_NAME = 2, 192*0e209d39SAndroid Build Coastguard Worker 193*0e209d39SAndroid Build Coastguard Worker /** 194*0e209d39SAndroid Build Coastguard Worker * Use the three-digit ISO XXX code in place of the symbol for displaying currencies. The behavior of this 195*0e209d39SAndroid Build Coastguard Worker * option is currently undefined for use with measure units. 196*0e209d39SAndroid Build Coastguard Worker * 197*0e209d39SAndroid Build Coastguard Worker * <p> 198*0e209d39SAndroid Build Coastguard Worker * In CLDR, this option corresponds to the "¤¤" placeholder for currencies. 199*0e209d39SAndroid Build Coastguard Worker * 200*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 201*0e209d39SAndroid Build Coastguard Worker */ 202*0e209d39SAndroid Build Coastguard Worker UNUM_UNIT_WIDTH_ISO_CODE = 3, 203*0e209d39SAndroid Build Coastguard Worker 204*0e209d39SAndroid Build Coastguard Worker /** 205*0e209d39SAndroid Build Coastguard Worker * Use the formal variant of the currency symbol; for example, "NT$" for the New Taiwan 206*0e209d39SAndroid Build Coastguard Worker * dollar in zh-TW. 207*0e209d39SAndroid Build Coastguard Worker * 208*0e209d39SAndroid Build Coastguard Worker * <p> 209*0e209d39SAndroid Build Coastguard Worker * Behavior of this option with non-currency units is not defined at this time. 210*0e209d39SAndroid Build Coastguard Worker * 211*0e209d39SAndroid Build Coastguard Worker * @stable ICU 68 212*0e209d39SAndroid Build Coastguard Worker */ 213*0e209d39SAndroid Build Coastguard Worker UNUM_UNIT_WIDTH_FORMAL = 4, 214*0e209d39SAndroid Build Coastguard Worker 215*0e209d39SAndroid Build Coastguard Worker /** 216*0e209d39SAndroid Build Coastguard Worker * Use the alternate variant of the currency symbol; for example, "TL" for the Turkish 217*0e209d39SAndroid Build Coastguard Worker * lira (TRY). 218*0e209d39SAndroid Build Coastguard Worker * 219*0e209d39SAndroid Build Coastguard Worker * <p> 220*0e209d39SAndroid Build Coastguard Worker * Behavior of this option with non-currency units is not defined at this time. 221*0e209d39SAndroid Build Coastguard Worker * 222*0e209d39SAndroid Build Coastguard Worker * @stable ICU 68 223*0e209d39SAndroid Build Coastguard Worker */ 224*0e209d39SAndroid Build Coastguard Worker UNUM_UNIT_WIDTH_VARIANT = 5, 225*0e209d39SAndroid Build Coastguard Worker 226*0e209d39SAndroid Build Coastguard Worker /** 227*0e209d39SAndroid Build Coastguard Worker * Format the number according to the specified unit, but do not display the unit. For currencies, apply 228*0e209d39SAndroid Build Coastguard Worker * monetary symbols and formats as with SHORT, but omit the currency symbol. For measure units, the behavior is 229*0e209d39SAndroid Build Coastguard Worker * equivalent to not specifying the unit at all. 230*0e209d39SAndroid Build Coastguard Worker * 231*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 232*0e209d39SAndroid Build Coastguard Worker */ 233*0e209d39SAndroid Build Coastguard Worker UNUM_UNIT_WIDTH_HIDDEN = 6, 234*0e209d39SAndroid Build Coastguard Worker 235*0e209d39SAndroid Build Coastguard Worker // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API, 236*0e209d39SAndroid Build Coastguard Worker // needed for unconditionalized struct MacroProps 237*0e209d39SAndroid Build Coastguard Worker /** 238*0e209d39SAndroid Build Coastguard Worker * One more than the highest UNumberUnitWidth value. 239*0e209d39SAndroid Build Coastguard Worker * 240*0e209d39SAndroid Build Coastguard Worker * @internal ICU 60: The numeric value may change over time; see ICU ticket #12420. 241*0e209d39SAndroid Build Coastguard Worker */ 242*0e209d39SAndroid Build Coastguard Worker UNUM_UNIT_WIDTH_COUNT = 7 243*0e209d39SAndroid Build Coastguard Worker } UNumberUnitWidth; 244*0e209d39SAndroid Build Coastguard Worker 245*0e209d39SAndroid Build Coastguard Worker /** 246*0e209d39SAndroid Build Coastguard Worker * An enum declaring how to denote positive and negative numbers. Example outputs when formatting 247*0e209d39SAndroid Build Coastguard Worker * 123, 0, and -123 in <em>en-US</em>: 248*0e209d39SAndroid Build Coastguard Worker * 249*0e209d39SAndroid Build Coastguard Worker * <ul> 250*0e209d39SAndroid Build Coastguard Worker * <li>AUTO: "123", "0", and "-123" 251*0e209d39SAndroid Build Coastguard Worker * <li>ALWAYS: "+123", "+0", and "-123" 252*0e209d39SAndroid Build Coastguard Worker * <li>NEVER: "123", "0", and "123" 253*0e209d39SAndroid Build Coastguard Worker * <li>ACCOUNTING: "$123", "$0", and "($123)" 254*0e209d39SAndroid Build Coastguard Worker * <li>ACCOUNTING_ALWAYS: "+$123", "+$0", and "($123)" 255*0e209d39SAndroid Build Coastguard Worker * <li>EXCEPT_ZERO: "+123", "0", and "-123" 256*0e209d39SAndroid Build Coastguard Worker * <li>ACCOUNTING_EXCEPT_ZERO: "+$123", "$0", and "($123)" 257*0e209d39SAndroid Build Coastguard Worker * </ul> 258*0e209d39SAndroid Build Coastguard Worker * 259*0e209d39SAndroid Build Coastguard Worker * <p> 260*0e209d39SAndroid Build Coastguard Worker * The exact format, including the position and the code point of the sign, differ by locale. 261*0e209d39SAndroid Build Coastguard Worker * 262*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 263*0e209d39SAndroid Build Coastguard Worker */ 264*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberSignDisplay { 265*0e209d39SAndroid Build Coastguard Worker /** 266*0e209d39SAndroid Build Coastguard Worker * Show the minus sign on negative numbers, and do not show the sign on positive numbers. This is the default 267*0e209d39SAndroid Build Coastguard Worker * behavior. 268*0e209d39SAndroid Build Coastguard Worker * 269*0e209d39SAndroid Build Coastguard Worker * If using this option, a sign will be displayed on negative zero, including negative numbers 270*0e209d39SAndroid Build Coastguard Worker * that round to zero. To hide the sign on negative zero, use the NEGATIVE option. 271*0e209d39SAndroid Build Coastguard Worker * 272*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 273*0e209d39SAndroid Build Coastguard Worker */ 274*0e209d39SAndroid Build Coastguard Worker UNUM_SIGN_AUTO, 275*0e209d39SAndroid Build Coastguard Worker 276*0e209d39SAndroid Build Coastguard Worker /** 277*0e209d39SAndroid Build Coastguard Worker * Show the minus sign on negative numbers and the plus sign on positive numbers, including zero. 278*0e209d39SAndroid Build Coastguard Worker * To hide the sign on zero, see {@link UNUM_SIGN_EXCEPT_ZERO}. 279*0e209d39SAndroid Build Coastguard Worker * 280*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 281*0e209d39SAndroid Build Coastguard Worker */ 282*0e209d39SAndroid Build Coastguard Worker UNUM_SIGN_ALWAYS, 283*0e209d39SAndroid Build Coastguard Worker 284*0e209d39SAndroid Build Coastguard Worker /** 285*0e209d39SAndroid Build Coastguard Worker * Do not show the sign on positive or negative numbers. 286*0e209d39SAndroid Build Coastguard Worker * 287*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 288*0e209d39SAndroid Build Coastguard Worker */ 289*0e209d39SAndroid Build Coastguard Worker UNUM_SIGN_NEVER, 290*0e209d39SAndroid Build Coastguard Worker 291*0e209d39SAndroid Build Coastguard Worker /** 292*0e209d39SAndroid Build Coastguard Worker * Use the locale-dependent accounting format on negative numbers, and do not show the sign on positive numbers. 293*0e209d39SAndroid Build Coastguard Worker * 294*0e209d39SAndroid Build Coastguard Worker * <p> 295*0e209d39SAndroid Build Coastguard Worker * The accounting format is defined in CLDR and varies by locale; in many Western locales, the format is a pair 296*0e209d39SAndroid Build Coastguard Worker * of parentheses around the number. 297*0e209d39SAndroid Build Coastguard Worker * 298*0e209d39SAndroid Build Coastguard Worker * <p> 299*0e209d39SAndroid Build Coastguard Worker * Note: Since CLDR defines the accounting format in the monetary context only, this option falls back to the 300*0e209d39SAndroid Build Coastguard Worker * AUTO sign display strategy when formatting without a currency unit. This limitation may be lifted in the 301*0e209d39SAndroid Build Coastguard Worker * future. 302*0e209d39SAndroid Build Coastguard Worker * 303*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 304*0e209d39SAndroid Build Coastguard Worker */ 305*0e209d39SAndroid Build Coastguard Worker UNUM_SIGN_ACCOUNTING, 306*0e209d39SAndroid Build Coastguard Worker 307*0e209d39SAndroid Build Coastguard Worker /** 308*0e209d39SAndroid Build Coastguard Worker * Use the locale-dependent accounting format on negative numbers, and show the plus sign on 309*0e209d39SAndroid Build Coastguard Worker * positive numbers, including zero. For more information on the accounting format, see the 310*0e209d39SAndroid Build Coastguard Worker * ACCOUNTING sign display strategy. To hide the sign on zero, see 311*0e209d39SAndroid Build Coastguard Worker * {@link UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO}. 312*0e209d39SAndroid Build Coastguard Worker * 313*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 314*0e209d39SAndroid Build Coastguard Worker */ 315*0e209d39SAndroid Build Coastguard Worker UNUM_SIGN_ACCOUNTING_ALWAYS, 316*0e209d39SAndroid Build Coastguard Worker 317*0e209d39SAndroid Build Coastguard Worker /** 318*0e209d39SAndroid Build Coastguard Worker * Show the minus sign on negative numbers and the plus sign on positive numbers. Do not show a 319*0e209d39SAndroid Build Coastguard Worker * sign on zero, numbers that round to zero, or NaN. 320*0e209d39SAndroid Build Coastguard Worker * 321*0e209d39SAndroid Build Coastguard Worker * @stable ICU 61 322*0e209d39SAndroid Build Coastguard Worker */ 323*0e209d39SAndroid Build Coastguard Worker UNUM_SIGN_EXCEPT_ZERO, 324*0e209d39SAndroid Build Coastguard Worker 325*0e209d39SAndroid Build Coastguard Worker /** 326*0e209d39SAndroid Build Coastguard Worker * Use the locale-dependent accounting format on negative numbers, and show the plus sign on 327*0e209d39SAndroid Build Coastguard Worker * positive numbers. Do not show a sign on zero, numbers that round to zero, or NaN. For more 328*0e209d39SAndroid Build Coastguard Worker * information on the accounting format, see the ACCOUNTING sign display strategy. 329*0e209d39SAndroid Build Coastguard Worker * 330*0e209d39SAndroid Build Coastguard Worker * @stable ICU 61 331*0e209d39SAndroid Build Coastguard Worker */ 332*0e209d39SAndroid Build Coastguard Worker UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO, 333*0e209d39SAndroid Build Coastguard Worker 334*0e209d39SAndroid Build Coastguard Worker /** 335*0e209d39SAndroid Build Coastguard Worker * Same as AUTO, but do not show the sign on negative zero. 336*0e209d39SAndroid Build Coastguard Worker * 337*0e209d39SAndroid Build Coastguard Worker * @stable ICU 69 338*0e209d39SAndroid Build Coastguard Worker */ 339*0e209d39SAndroid Build Coastguard Worker UNUM_SIGN_NEGATIVE, 340*0e209d39SAndroid Build Coastguard Worker 341*0e209d39SAndroid Build Coastguard Worker /** 342*0e209d39SAndroid Build Coastguard Worker * Same as ACCOUNTING, but do not show the sign on negative zero. 343*0e209d39SAndroid Build Coastguard Worker * 344*0e209d39SAndroid Build Coastguard Worker * @stable ICU 69 345*0e209d39SAndroid Build Coastguard Worker */ 346*0e209d39SAndroid Build Coastguard Worker UNUM_SIGN_ACCOUNTING_NEGATIVE, 347*0e209d39SAndroid Build Coastguard Worker 348*0e209d39SAndroid Build Coastguard Worker // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API, 349*0e209d39SAndroid Build Coastguard Worker // needed for unconditionalized struct MacroProps 350*0e209d39SAndroid Build Coastguard Worker /** 351*0e209d39SAndroid Build Coastguard Worker * One more than the highest UNumberSignDisplay value. 352*0e209d39SAndroid Build Coastguard Worker * 353*0e209d39SAndroid Build Coastguard Worker * @internal ICU 60: The numeric value may change over time; see ICU ticket #12420. 354*0e209d39SAndroid Build Coastguard Worker */ 355*0e209d39SAndroid Build Coastguard Worker UNUM_SIGN_COUNT = 9, 356*0e209d39SAndroid Build Coastguard Worker } UNumberSignDisplay; 357*0e209d39SAndroid Build Coastguard Worker 358*0e209d39SAndroid Build Coastguard Worker /** 359*0e209d39SAndroid Build Coastguard Worker * An enum declaring how to render the decimal separator. 360*0e209d39SAndroid Build Coastguard Worker * 361*0e209d39SAndroid Build Coastguard Worker * <p> 362*0e209d39SAndroid Build Coastguard Worker * <ul> 363*0e209d39SAndroid Build Coastguard Worker * <li>UNUM_DECIMAL_SEPARATOR_AUTO: "1", "1.1" 364*0e209d39SAndroid Build Coastguard Worker * <li>UNUM_DECIMAL_SEPARATOR_ALWAYS: "1.", "1.1" 365*0e209d39SAndroid Build Coastguard Worker * </ul> 366*0e209d39SAndroid Build Coastguard Worker * 367*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 368*0e209d39SAndroid Build Coastguard Worker */ 369*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberDecimalSeparatorDisplay { 370*0e209d39SAndroid Build Coastguard Worker /** 371*0e209d39SAndroid Build Coastguard Worker * Show the decimal separator when there are one or more digits to display after the separator, and do not show 372*0e209d39SAndroid Build Coastguard Worker * it otherwise. This is the default behavior. 373*0e209d39SAndroid Build Coastguard Worker * 374*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 375*0e209d39SAndroid Build Coastguard Worker */ 376*0e209d39SAndroid Build Coastguard Worker UNUM_DECIMAL_SEPARATOR_AUTO, 377*0e209d39SAndroid Build Coastguard Worker 378*0e209d39SAndroid Build Coastguard Worker /** 379*0e209d39SAndroid Build Coastguard Worker * Always show the decimal separator, even if there are no digits to display after the separator. 380*0e209d39SAndroid Build Coastguard Worker * 381*0e209d39SAndroid Build Coastguard Worker * @stable ICU 60 382*0e209d39SAndroid Build Coastguard Worker */ 383*0e209d39SAndroid Build Coastguard Worker UNUM_DECIMAL_SEPARATOR_ALWAYS, 384*0e209d39SAndroid Build Coastguard Worker 385*0e209d39SAndroid Build Coastguard Worker // Do not conditionalize the following with #ifndef U_HIDE_INTERNAL_API, 386*0e209d39SAndroid Build Coastguard Worker // needed for unconditionalized struct MacroProps 387*0e209d39SAndroid Build Coastguard Worker /** 388*0e209d39SAndroid Build Coastguard Worker * One more than the highest UNumberDecimalSeparatorDisplay value. 389*0e209d39SAndroid Build Coastguard Worker * 390*0e209d39SAndroid Build Coastguard Worker * @internal ICU 60: The numeric value may change over time; see ICU ticket #12420. 391*0e209d39SAndroid Build Coastguard Worker */ 392*0e209d39SAndroid Build Coastguard Worker UNUM_DECIMAL_SEPARATOR_COUNT 393*0e209d39SAndroid Build Coastguard Worker } UNumberDecimalSeparatorDisplay; 394*0e209d39SAndroid Build Coastguard Worker 395*0e209d39SAndroid Build Coastguard Worker /** 396*0e209d39SAndroid Build Coastguard Worker * An enum declaring how to render trailing zeros. 397*0e209d39SAndroid Build Coastguard Worker * 398*0e209d39SAndroid Build Coastguard Worker * - UNUM_TRAILING_ZERO_AUTO: 0.90, 1.00, 1.10 399*0e209d39SAndroid Build Coastguard Worker * - UNUM_TRAILING_ZERO_HIDE_IF_WHOLE: 0.90, 1, 1.10 400*0e209d39SAndroid Build Coastguard Worker * 401*0e209d39SAndroid Build Coastguard Worker * @stable ICU 69 402*0e209d39SAndroid Build Coastguard Worker */ 403*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberTrailingZeroDisplay { 404*0e209d39SAndroid Build Coastguard Worker /** 405*0e209d39SAndroid Build Coastguard Worker * Display trailing zeros according to the settings for minimum fraction and significant digits. 406*0e209d39SAndroid Build Coastguard Worker * 407*0e209d39SAndroid Build Coastguard Worker * @stable ICU 69 408*0e209d39SAndroid Build Coastguard Worker */ 409*0e209d39SAndroid Build Coastguard Worker UNUM_TRAILING_ZERO_AUTO, 410*0e209d39SAndroid Build Coastguard Worker 411*0e209d39SAndroid Build Coastguard Worker /** 412*0e209d39SAndroid Build Coastguard Worker * Same as AUTO, but hide trailing zeros after the decimal separator if they are all zero. 413*0e209d39SAndroid Build Coastguard Worker * 414*0e209d39SAndroid Build Coastguard Worker * @stable ICU 69 415*0e209d39SAndroid Build Coastguard Worker */ 416*0e209d39SAndroid Build Coastguard Worker UNUM_TRAILING_ZERO_HIDE_IF_WHOLE, 417*0e209d39SAndroid Build Coastguard Worker } UNumberTrailingZeroDisplay; 418*0e209d39SAndroid Build Coastguard Worker 419*0e209d39SAndroid Build Coastguard Worker struct UNumberFormatter; 420*0e209d39SAndroid Build Coastguard Worker /** 421*0e209d39SAndroid Build Coastguard Worker * C-compatible version of icu::number::LocalizedNumberFormatter. 422*0e209d39SAndroid Build Coastguard Worker * 423*0e209d39SAndroid Build Coastguard Worker * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead. 424*0e209d39SAndroid Build Coastguard Worker * 425*0e209d39SAndroid Build Coastguard Worker * @stable ICU 62 426*0e209d39SAndroid Build Coastguard Worker */ 427*0e209d39SAndroid Build Coastguard Worker typedef struct UNumberFormatter UNumberFormatter; 428*0e209d39SAndroid Build Coastguard Worker 429*0e209d39SAndroid Build Coastguard Worker 430*0e209d39SAndroid Build Coastguard Worker /** 431*0e209d39SAndroid Build Coastguard Worker * Creates a new UNumberFormatter for the given skeleton string and locale. This is currently the only 432*0e209d39SAndroid Build Coastguard Worker * method for creating a new UNumberFormatter. 433*0e209d39SAndroid Build Coastguard Worker * 434*0e209d39SAndroid Build Coastguard Worker * Objects of type UNumberFormatter returned by this method are threadsafe. 435*0e209d39SAndroid Build Coastguard Worker * 436*0e209d39SAndroid Build Coastguard Worker * For more details on skeleton strings, see the documentation in numberformatter.h. For more details on 437*0e209d39SAndroid Build Coastguard Worker * the usage of this API, see the documentation at the top of unumberformatter.h. 438*0e209d39SAndroid Build Coastguard Worker * 439*0e209d39SAndroid Build Coastguard Worker * For more information on number skeleton strings, see: 440*0e209d39SAndroid Build Coastguard Worker * https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html 441*0e209d39SAndroid Build Coastguard Worker * 442*0e209d39SAndroid Build Coastguard Worker * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead. 443*0e209d39SAndroid Build Coastguard Worker * 444*0e209d39SAndroid Build Coastguard Worker * @param skeleton The skeleton string, like u"percent precision-integer" 445*0e209d39SAndroid Build Coastguard Worker * @param skeletonLen The number of UChars in the skeleton string, or -1 if it is NUL-terminated. 446*0e209d39SAndroid Build Coastguard Worker * @param locale The NUL-terminated locale ID. 447*0e209d39SAndroid Build Coastguard Worker * @param ec Set if an error occurs. 448*0e209d39SAndroid Build Coastguard Worker * @stable ICU 62 449*0e209d39SAndroid Build Coastguard Worker */ 450*0e209d39SAndroid Build Coastguard Worker U_CAPI UNumberFormatter* U_EXPORT2 451*0e209d39SAndroid Build Coastguard Worker unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const char* locale, 452*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec); 453*0e209d39SAndroid Build Coastguard Worker 454*0e209d39SAndroid Build Coastguard Worker 455*0e209d39SAndroid Build Coastguard Worker /** 456*0e209d39SAndroid Build Coastguard Worker * Like unumf_openForSkeletonAndLocale, but accepts a UParseError, which will be populated with the 457*0e209d39SAndroid Build Coastguard Worker * location of a skeleton syntax error if such a syntax error exists. 458*0e209d39SAndroid Build Coastguard Worker * 459*0e209d39SAndroid Build Coastguard Worker * For more information on number skeleton strings, see: 460*0e209d39SAndroid Build Coastguard Worker * https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html 461*0e209d39SAndroid Build Coastguard Worker * 462*0e209d39SAndroid Build Coastguard Worker * @param skeleton The skeleton string, like u"percent precision-integer" 463*0e209d39SAndroid Build Coastguard Worker * @param skeletonLen The number of UChars in the skeleton string, or -1 if it is NUL-terminated. 464*0e209d39SAndroid Build Coastguard Worker * @param locale The NUL-terminated locale ID. 465*0e209d39SAndroid Build Coastguard Worker * @param perror A parse error struct populated if an error occurs when parsing. Can be NULL. 466*0e209d39SAndroid Build Coastguard Worker * If no error occurs, perror->offset will be set to -1. 467*0e209d39SAndroid Build Coastguard Worker * @param ec Set if an error occurs. 468*0e209d39SAndroid Build Coastguard Worker * @stable ICU 64 469*0e209d39SAndroid Build Coastguard Worker */ 470*0e209d39SAndroid Build Coastguard Worker U_CAPI UNumberFormatter* U_EXPORT2 471*0e209d39SAndroid Build Coastguard Worker unumf_openForSkeletonAndLocaleWithError( 472*0e209d39SAndroid Build Coastguard Worker const UChar* skeleton, int32_t skeletonLen, const char* locale, UParseError* perror, UErrorCode* ec); 473*0e209d39SAndroid Build Coastguard Worker 474*0e209d39SAndroid Build Coastguard Worker 475*0e209d39SAndroid Build Coastguard Worker 476*0e209d39SAndroid Build Coastguard Worker /** 477*0e209d39SAndroid Build Coastguard Worker * Uses a UNumberFormatter to format an integer to a UFormattedNumber. A string, field position, and other 478*0e209d39SAndroid Build Coastguard Worker * information can be retrieved from the UFormattedNumber. 479*0e209d39SAndroid Build Coastguard Worker * 480*0e209d39SAndroid Build Coastguard Worker * The UNumberFormatter can be shared between threads. Each thread should have its own local 481*0e209d39SAndroid Build Coastguard Worker * UFormattedNumber, however, for storing the result of the formatting operation. 482*0e209d39SAndroid Build Coastguard Worker * 483*0e209d39SAndroid Build Coastguard Worker * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead. 484*0e209d39SAndroid Build Coastguard Worker * 485*0e209d39SAndroid Build Coastguard Worker * @param uformatter A formatter object created by unumf_openForSkeletonAndLocale or similar. 486*0e209d39SAndroid Build Coastguard Worker * @param value The number to be formatted. 487*0e209d39SAndroid Build Coastguard Worker * @param uresult The object that will be mutated to store the result; see unumf_openResult. 488*0e209d39SAndroid Build Coastguard Worker * @param ec Set if an error occurs. 489*0e209d39SAndroid Build Coastguard Worker * @stable ICU 62 490*0e209d39SAndroid Build Coastguard Worker */ 491*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 492*0e209d39SAndroid Build Coastguard Worker unumf_formatInt(const UNumberFormatter* uformatter, int64_t value, UFormattedNumber* uresult, 493*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec); 494*0e209d39SAndroid Build Coastguard Worker 495*0e209d39SAndroid Build Coastguard Worker 496*0e209d39SAndroid Build Coastguard Worker /** 497*0e209d39SAndroid Build Coastguard Worker * Uses a UNumberFormatter to format a double to a UFormattedNumber. A string, field position, and other 498*0e209d39SAndroid Build Coastguard Worker * information can be retrieved from the UFormattedNumber. 499*0e209d39SAndroid Build Coastguard Worker * 500*0e209d39SAndroid Build Coastguard Worker * The UNumberFormatter can be shared between threads. Each thread should have its own local 501*0e209d39SAndroid Build Coastguard Worker * UFormattedNumber, however, for storing the result of the formatting operation. 502*0e209d39SAndroid Build Coastguard Worker * 503*0e209d39SAndroid Build Coastguard Worker * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead. 504*0e209d39SAndroid Build Coastguard Worker * 505*0e209d39SAndroid Build Coastguard Worker * @param uformatter A formatter object created by unumf_openForSkeletonAndLocale or similar. 506*0e209d39SAndroid Build Coastguard Worker * @param value The number to be formatted. 507*0e209d39SAndroid Build Coastguard Worker * @param uresult The object that will be mutated to store the result; see unumf_openResult. 508*0e209d39SAndroid Build Coastguard Worker * @param ec Set if an error occurs. 509*0e209d39SAndroid Build Coastguard Worker * @stable ICU 62 510*0e209d39SAndroid Build Coastguard Worker */ 511*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 512*0e209d39SAndroid Build Coastguard Worker unumf_formatDouble(const UNumberFormatter* uformatter, double value, UFormattedNumber* uresult, 513*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec); 514*0e209d39SAndroid Build Coastguard Worker 515*0e209d39SAndroid Build Coastguard Worker 516*0e209d39SAndroid Build Coastguard Worker /** 517*0e209d39SAndroid Build Coastguard Worker * Uses a UNumberFormatter to format a decimal number to a UFormattedNumber. A string, field position, and 518*0e209d39SAndroid Build Coastguard Worker * other information can be retrieved from the UFormattedNumber. 519*0e209d39SAndroid Build Coastguard Worker * 520*0e209d39SAndroid Build Coastguard Worker * The UNumberFormatter can be shared between threads. Each thread should have its own local 521*0e209d39SAndroid Build Coastguard Worker * UFormattedNumber, however, for storing the result of the formatting operation. 522*0e209d39SAndroid Build Coastguard Worker * 523*0e209d39SAndroid Build Coastguard Worker * The syntax of the unformatted number is a "numeric string" as defined in the Decimal Arithmetic 524*0e209d39SAndroid Build Coastguard Worker * Specification, available at http://speleotrove.com/decimal 525*0e209d39SAndroid Build Coastguard Worker * 526*0e209d39SAndroid Build Coastguard Worker * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead. 527*0e209d39SAndroid Build Coastguard Worker * 528*0e209d39SAndroid Build Coastguard Worker * @param uformatter A formatter object created by unumf_openForSkeletonAndLocale or similar. 529*0e209d39SAndroid Build Coastguard Worker * @param value The numeric string to be formatted. 530*0e209d39SAndroid Build Coastguard Worker * @param valueLen The length of the numeric string, or -1 if it is NUL-terminated. 531*0e209d39SAndroid Build Coastguard Worker * @param uresult The object that will be mutated to store the result; see unumf_openResult. 532*0e209d39SAndroid Build Coastguard Worker * @param ec Set if an error occurs. 533*0e209d39SAndroid Build Coastguard Worker * @stable ICU 62 534*0e209d39SAndroid Build Coastguard Worker */ 535*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 536*0e209d39SAndroid Build Coastguard Worker unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32_t valueLen, 537*0e209d39SAndroid Build Coastguard Worker UFormattedNumber* uresult, UErrorCode* ec); 538*0e209d39SAndroid Build Coastguard Worker 539*0e209d39SAndroid Build Coastguard Worker 540*0e209d39SAndroid Build Coastguard Worker 541*0e209d39SAndroid Build Coastguard Worker /** 542*0e209d39SAndroid Build Coastguard Worker * Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale(). 543*0e209d39SAndroid Build Coastguard Worker * 544*0e209d39SAndroid Build Coastguard Worker * @param uformatter An object created by unumf_openForSkeletonAndLocale(). 545*0e209d39SAndroid Build Coastguard Worker * @stable ICU 62 546*0e209d39SAndroid Build Coastguard Worker */ 547*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 548*0e209d39SAndroid Build Coastguard Worker unumf_close(UNumberFormatter* uformatter); 549*0e209d39SAndroid Build Coastguard Worker 550*0e209d39SAndroid Build Coastguard Worker 551*0e209d39SAndroid Build Coastguard Worker 552*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 553*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 554*0e209d39SAndroid Build Coastguard Worker 555*0e209d39SAndroid Build Coastguard Worker /** 556*0e209d39SAndroid Build Coastguard Worker * \class LocalUNumberFormatterPointer 557*0e209d39SAndroid Build Coastguard Worker * "Smart pointer" class; closes a UNumberFormatter via unumf_close(). 558*0e209d39SAndroid Build Coastguard Worker * For most methods see the LocalPointerBase base class. 559*0e209d39SAndroid Build Coastguard Worker * 560*0e209d39SAndroid Build Coastguard Worker * Usage: 561*0e209d39SAndroid Build Coastguard Worker * <pre> 562*0e209d39SAndroid Build Coastguard Worker * LocalUNumberFormatterPointer uformatter(unumf_openForSkeletonAndLocale(...)); 563*0e209d39SAndroid Build Coastguard Worker * // no need to explicitly call unumf_close() 564*0e209d39SAndroid Build Coastguard Worker * </pre> 565*0e209d39SAndroid Build Coastguard Worker * 566*0e209d39SAndroid Build Coastguard Worker * @see LocalPointerBase 567*0e209d39SAndroid Build Coastguard Worker * @see LocalPointer 568*0e209d39SAndroid Build Coastguard Worker * @stable ICU 62 569*0e209d39SAndroid Build Coastguard Worker */ 570*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatterPointer, UNumberFormatter, unumf_close); 571*0e209d39SAndroid Build Coastguard Worker 572*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 573*0e209d39SAndroid Build Coastguard Worker #endif // U_SHOW_CPLUSPLUS_API 574*0e209d39SAndroid Build Coastguard Worker 575*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_FORMATTING */ 576*0e209d39SAndroid Build Coastguard Worker #endif //__UNUMBERFORMATTER_H__ 577