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) 1997-2015, International Business Machines Corporation and others. 6*0e209d39SAndroid Build Coastguard Worker * All Rights Reserved. 7*0e209d39SAndroid Build Coastguard Worker * Modification History: 8*0e209d39SAndroid Build Coastguard Worker * 9*0e209d39SAndroid Build Coastguard Worker * Date Name Description 10*0e209d39SAndroid Build Coastguard Worker * 06/24/99 helena Integrated Alan's NF enhancements and Java2 bug fixes 11*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 12*0e209d39SAndroid Build Coastguard Worker */ 13*0e209d39SAndroid Build Coastguard Worker 14*0e209d39SAndroid Build Coastguard Worker #ifndef _UNUM 15*0e209d39SAndroid Build Coastguard Worker #define _UNUM 16*0e209d39SAndroid Build Coastguard Worker 17*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 18*0e209d39SAndroid Build Coastguard Worker 19*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING 20*0e209d39SAndroid Build Coastguard Worker 21*0e209d39SAndroid Build Coastguard Worker #include "unicode/uloc.h" 22*0e209d39SAndroid Build Coastguard Worker #include "unicode/ucurr.h" 23*0e209d39SAndroid Build Coastguard Worker #include "unicode/umisc.h" 24*0e209d39SAndroid Build Coastguard Worker #include "unicode/parseerr.h" 25*0e209d39SAndroid Build Coastguard Worker #include "unicode/uformattable.h" 26*0e209d39SAndroid Build Coastguard Worker #include "unicode/udisplaycontext.h" 27*0e209d39SAndroid Build Coastguard Worker #include "unicode/ufieldpositer.h" 28*0e209d39SAndroid Build Coastguard Worker #include "unicode/unumberoptions.h" 29*0e209d39SAndroid Build Coastguard Worker 30*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 31*0e209d39SAndroid Build Coastguard Worker #include "unicode/localpointer.h" 32*0e209d39SAndroid Build Coastguard Worker #endif // U_SHOW_CPLUSPLUS_API 33*0e209d39SAndroid Build Coastguard Worker 34*0e209d39SAndroid Build Coastguard Worker /** 35*0e209d39SAndroid Build Coastguard Worker * \file 36*0e209d39SAndroid Build Coastguard Worker * \brief C API: Compatibility APIs for number formatting. 37*0e209d39SAndroid Build Coastguard Worker * 38*0e209d39SAndroid Build Coastguard Worker * <h2> Number Format C API </h2> 39*0e209d39SAndroid Build Coastguard Worker * 40*0e209d39SAndroid Build Coastguard Worker * <p><strong>IMPORTANT:</strong> New users with are strongly encouraged to 41*0e209d39SAndroid Build Coastguard Worker * see if unumberformatter.h fits their use case. Although not deprecated, 42*0e209d39SAndroid Build Coastguard Worker * this header is provided for backwards compatibility only. 43*0e209d39SAndroid Build Coastguard Worker * 44*0e209d39SAndroid Build Coastguard Worker * Number Format C API Provides functions for 45*0e209d39SAndroid Build Coastguard Worker * formatting and parsing a number. Also provides methods for 46*0e209d39SAndroid Build Coastguard Worker * determining which locales have number formats, and what their names 47*0e209d39SAndroid Build Coastguard Worker * are. 48*0e209d39SAndroid Build Coastguard Worker * <P> 49*0e209d39SAndroid Build Coastguard Worker * UNumberFormat helps you to format and parse numbers for any locale. 50*0e209d39SAndroid Build Coastguard Worker * Your code can be completely independent of the locale conventions 51*0e209d39SAndroid Build Coastguard Worker * for decimal points, thousands-separators, or even the particular 52*0e209d39SAndroid Build Coastguard Worker * decimal digits used, or whether the number format is even decimal. 53*0e209d39SAndroid Build Coastguard Worker * There are different number format styles like decimal, currency, 54*0e209d39SAndroid Build Coastguard Worker * percent and spellout. 55*0e209d39SAndroid Build Coastguard Worker * <P> 56*0e209d39SAndroid Build Coastguard Worker * To format a number for the current Locale, use one of the static 57*0e209d39SAndroid Build Coastguard Worker * factory methods: 58*0e209d39SAndroid Build Coastguard Worker * <pre> 59*0e209d39SAndroid Build Coastguard Worker * \code 60*0e209d39SAndroid Build Coastguard Worker * UChar myString[20]; 61*0e209d39SAndroid Build Coastguard Worker * double myNumber = 7.0; 62*0e209d39SAndroid Build Coastguard Worker * UErrorCode status = U_ZERO_ERROR; 63*0e209d39SAndroid Build Coastguard Worker * UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, -1, NULL, NULL, &status); 64*0e209d39SAndroid Build Coastguard Worker * unum_formatDouble(nf, myNumber, myString, 20, NULL, &status); 65*0e209d39SAndroid Build Coastguard Worker * printf(" Example 1: %s\n", austrdup(myString) ); //austrdup( a function used to convert UChar* to char*) 66*0e209d39SAndroid Build Coastguard Worker * \endcode 67*0e209d39SAndroid Build Coastguard Worker * </pre> 68*0e209d39SAndroid Build Coastguard Worker * If you are formatting multiple numbers, it is more efficient to get 69*0e209d39SAndroid Build Coastguard Worker * the format and use it multiple times so that the system doesn't 70*0e209d39SAndroid Build Coastguard Worker * have to fetch the information about the local language and country 71*0e209d39SAndroid Build Coastguard Worker * conventions multiple times. 72*0e209d39SAndroid Build Coastguard Worker * <pre> 73*0e209d39SAndroid Build Coastguard Worker * \code 74*0e209d39SAndroid Build Coastguard Worker * uint32_t i, resultlength, reslenneeded; 75*0e209d39SAndroid Build Coastguard Worker * UErrorCode status = U_ZERO_ERROR; 76*0e209d39SAndroid Build Coastguard Worker * UFieldPosition pos; 77*0e209d39SAndroid Build Coastguard Worker * uint32_t a[] = { 123, 3333, -1234567 }; 78*0e209d39SAndroid Build Coastguard Worker * const uint32_t a_len = sizeof(a) / sizeof(a[0]); 79*0e209d39SAndroid Build Coastguard Worker * UNumberFormat* nf; 80*0e209d39SAndroid Build Coastguard Worker * UChar* result = NULL; 81*0e209d39SAndroid Build Coastguard Worker * 82*0e209d39SAndroid Build Coastguard Worker * nf = unum_open(UNUM_DEFAULT, NULL, -1, NULL, NULL, &status); 83*0e209d39SAndroid Build Coastguard Worker * for (i = 0; i < a_len; i++) { 84*0e209d39SAndroid Build Coastguard Worker * resultlength=0; 85*0e209d39SAndroid Build Coastguard Worker * reslenneeded=unum_format(nf, a[i], NULL, resultlength, &pos, &status); 86*0e209d39SAndroid Build Coastguard Worker * result = NULL; 87*0e209d39SAndroid Build Coastguard Worker * if(status==U_BUFFER_OVERFLOW_ERROR){ 88*0e209d39SAndroid Build Coastguard Worker * status=U_ZERO_ERROR; 89*0e209d39SAndroid Build Coastguard Worker * resultlength=reslenneeded+1; 90*0e209d39SAndroid Build Coastguard Worker * result=(UChar*)malloc(sizeof(UChar) * resultlength); 91*0e209d39SAndroid Build Coastguard Worker * unum_format(nf, a[i], result, resultlength, &pos, &status); 92*0e209d39SAndroid Build Coastguard Worker * } 93*0e209d39SAndroid Build Coastguard Worker * printf( " Example 2: %s\n", austrdup(result)); 94*0e209d39SAndroid Build Coastguard Worker * free(result); 95*0e209d39SAndroid Build Coastguard Worker * } 96*0e209d39SAndroid Build Coastguard Worker * \endcode 97*0e209d39SAndroid Build Coastguard Worker * </pre> 98*0e209d39SAndroid Build Coastguard Worker * To format a number for a different Locale, specify it in the 99*0e209d39SAndroid Build Coastguard Worker * call to unum_open(). 100*0e209d39SAndroid Build Coastguard Worker * <pre> 101*0e209d39SAndroid Build Coastguard Worker * \code 102*0e209d39SAndroid Build Coastguard Worker * UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, -1, "fr_FR", NULL, &success) 103*0e209d39SAndroid Build Coastguard Worker * \endcode 104*0e209d39SAndroid Build Coastguard Worker * </pre> 105*0e209d39SAndroid Build Coastguard Worker * You can use a NumberFormat API unum_parse() to parse. 106*0e209d39SAndroid Build Coastguard Worker * <pre> 107*0e209d39SAndroid Build Coastguard Worker * \code 108*0e209d39SAndroid Build Coastguard Worker * UErrorCode status = U_ZERO_ERROR; 109*0e209d39SAndroid Build Coastguard Worker * int32_t pos=0; 110*0e209d39SAndroid Build Coastguard Worker * int32_t num; 111*0e209d39SAndroid Build Coastguard Worker * num = unum_parse(nf, str, u_strlen(str), &pos, &status); 112*0e209d39SAndroid Build Coastguard Worker * \endcode 113*0e209d39SAndroid Build Coastguard Worker * </pre> 114*0e209d39SAndroid Build Coastguard Worker * Use UNUM_DECIMAL to get the normal number format for that country. 115*0e209d39SAndroid Build Coastguard Worker * There are other static options available. Use UNUM_CURRENCY 116*0e209d39SAndroid Build Coastguard Worker * to get the currency number format for that country. Use UNUM_PERCENT 117*0e209d39SAndroid Build Coastguard Worker * to get a format for displaying percentages. With this format, a 118*0e209d39SAndroid Build Coastguard Worker * fraction from 0.53 is displayed as 53%. 119*0e209d39SAndroid Build Coastguard Worker * <P> 120*0e209d39SAndroid Build Coastguard Worker * Use a pattern to create either a DecimalFormat or a RuleBasedNumberFormat 121*0e209d39SAndroid Build Coastguard Worker * formatter. The pattern must conform to the syntax defined for those 122*0e209d39SAndroid Build Coastguard Worker * formatters. 123*0e209d39SAndroid Build Coastguard Worker * <P> 124*0e209d39SAndroid Build Coastguard Worker * You can also control the display of numbers with such function as 125*0e209d39SAndroid Build Coastguard Worker * unum_getAttributes() and unum_setAttributes(), which let you set the 126*0e209d39SAndroid Build Coastguard Worker * minimum fraction digits, grouping, etc. 127*0e209d39SAndroid Build Coastguard Worker * @see UNumberFormatAttributes for more details 128*0e209d39SAndroid Build Coastguard Worker * <P> 129*0e209d39SAndroid Build Coastguard Worker * You can also use forms of the parse and format methods with 130*0e209d39SAndroid Build Coastguard Worker * ParsePosition and UFieldPosition to allow you to: 131*0e209d39SAndroid Build Coastguard Worker * <ul type=round> 132*0e209d39SAndroid Build Coastguard Worker * <li>(a) progressively parse through pieces of a string. 133*0e209d39SAndroid Build Coastguard Worker * <li>(b) align the decimal point and other areas. 134*0e209d39SAndroid Build Coastguard Worker * </ul> 135*0e209d39SAndroid Build Coastguard Worker * <p> 136*0e209d39SAndroid Build Coastguard Worker * It is also possible to change or set the symbols used for a particular 137*0e209d39SAndroid Build Coastguard Worker * locale like the currency symbol, the grouping separator , monetary separator 138*0e209d39SAndroid Build Coastguard Worker * etc by making use of functions unum_setSymbols() and unum_getSymbols(). 139*0e209d39SAndroid Build Coastguard Worker */ 140*0e209d39SAndroid Build Coastguard Worker 141*0e209d39SAndroid Build Coastguard Worker /** A number formatter. 142*0e209d39SAndroid Build Coastguard Worker * For usage in C programs. 143*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 144*0e209d39SAndroid Build Coastguard Worker */ 145*0e209d39SAndroid Build Coastguard Worker typedef void* UNumberFormat; 146*0e209d39SAndroid Build Coastguard Worker 147*0e209d39SAndroid Build Coastguard Worker /** The possible number format styles. 148*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 149*0e209d39SAndroid Build Coastguard Worker */ 150*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberFormatStyle { 151*0e209d39SAndroid Build Coastguard Worker /** 152*0e209d39SAndroid Build Coastguard Worker * Decimal format defined by a pattern string. 153*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 154*0e209d39SAndroid Build Coastguard Worker */ 155*0e209d39SAndroid Build Coastguard Worker UNUM_PATTERN_DECIMAL=0, 156*0e209d39SAndroid Build Coastguard Worker /** 157*0e209d39SAndroid Build Coastguard Worker * Decimal format ("normal" style). 158*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 159*0e209d39SAndroid Build Coastguard Worker */ 160*0e209d39SAndroid Build Coastguard Worker UNUM_DECIMAL=1, 161*0e209d39SAndroid Build Coastguard Worker /** 162*0e209d39SAndroid Build Coastguard Worker * Currency format (generic). 163*0e209d39SAndroid Build Coastguard Worker * Defaults to UNUM_CURRENCY_STANDARD style 164*0e209d39SAndroid Build Coastguard Worker * (using currency symbol, e.g., "$1.00", with non-accounting 165*0e209d39SAndroid Build Coastguard Worker * style for negative values e.g. using minus sign). 166*0e209d39SAndroid Build Coastguard Worker * The specific style may be specified using the -cf- locale key. 167*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 168*0e209d39SAndroid Build Coastguard Worker */ 169*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY=2, 170*0e209d39SAndroid Build Coastguard Worker /** 171*0e209d39SAndroid Build Coastguard Worker * Percent format 172*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 173*0e209d39SAndroid Build Coastguard Worker */ 174*0e209d39SAndroid Build Coastguard Worker UNUM_PERCENT=3, 175*0e209d39SAndroid Build Coastguard Worker /** 176*0e209d39SAndroid Build Coastguard Worker * Scientific format 177*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.1 178*0e209d39SAndroid Build Coastguard Worker */ 179*0e209d39SAndroid Build Coastguard Worker UNUM_SCIENTIFIC=4, 180*0e209d39SAndroid Build Coastguard Worker /** 181*0e209d39SAndroid Build Coastguard Worker * Spellout rule-based format. The default ruleset can be specified/changed using 182*0e209d39SAndroid Build Coastguard Worker * unum_setTextAttribute with UNUM_DEFAULT_RULESET; the available public rulesets 183*0e209d39SAndroid Build Coastguard Worker * can be listed using unum_getTextAttribute with UNUM_PUBLIC_RULESETS. 184*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 185*0e209d39SAndroid Build Coastguard Worker */ 186*0e209d39SAndroid Build Coastguard Worker UNUM_SPELLOUT=5, 187*0e209d39SAndroid Build Coastguard Worker /** 188*0e209d39SAndroid Build Coastguard Worker * Ordinal rule-based format . The default ruleset can be specified/changed using 189*0e209d39SAndroid Build Coastguard Worker * unum_setTextAttribute with UNUM_DEFAULT_RULESET; the available public rulesets 190*0e209d39SAndroid Build Coastguard Worker * can be listed using unum_getTextAttribute with UNUM_PUBLIC_RULESETS. 191*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 192*0e209d39SAndroid Build Coastguard Worker */ 193*0e209d39SAndroid Build Coastguard Worker UNUM_ORDINAL=6, 194*0e209d39SAndroid Build Coastguard Worker /** 195*0e209d39SAndroid Build Coastguard Worker * Duration rule-based format 196*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 197*0e209d39SAndroid Build Coastguard Worker */ 198*0e209d39SAndroid Build Coastguard Worker UNUM_DURATION=7, 199*0e209d39SAndroid Build Coastguard Worker /** 200*0e209d39SAndroid Build Coastguard Worker * Numbering system rule-based format 201*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.2 202*0e209d39SAndroid Build Coastguard Worker */ 203*0e209d39SAndroid Build Coastguard Worker UNUM_NUMBERING_SYSTEM=8, 204*0e209d39SAndroid Build Coastguard Worker /** 205*0e209d39SAndroid Build Coastguard Worker * Rule-based format defined by a pattern string. 206*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 207*0e209d39SAndroid Build Coastguard Worker */ 208*0e209d39SAndroid Build Coastguard Worker UNUM_PATTERN_RULEBASED=9, 209*0e209d39SAndroid Build Coastguard Worker /** 210*0e209d39SAndroid Build Coastguard Worker * Currency format with an ISO currency code, e.g., "USD1.00". 211*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.8 212*0e209d39SAndroid Build Coastguard Worker */ 213*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY_ISO=10, 214*0e209d39SAndroid Build Coastguard Worker /** 215*0e209d39SAndroid Build Coastguard Worker * Currency format with a pluralized currency name, 216*0e209d39SAndroid Build Coastguard Worker * e.g., "1.00 US dollar" and "3.00 US dollars". 217*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.8 218*0e209d39SAndroid Build Coastguard Worker */ 219*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY_PLURAL=11, 220*0e209d39SAndroid Build Coastguard Worker /** 221*0e209d39SAndroid Build Coastguard Worker * Currency format for accounting, e.g., "($3.00)" for 222*0e209d39SAndroid Build Coastguard Worker * negative currency amount instead of "-$3.00" ({@link #UNUM_CURRENCY}). 223*0e209d39SAndroid Build Coastguard Worker * Overrides any style specified using -cf- key in locale. 224*0e209d39SAndroid Build Coastguard Worker * @stable ICU 53 225*0e209d39SAndroid Build Coastguard Worker */ 226*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY_ACCOUNTING=12, 227*0e209d39SAndroid Build Coastguard Worker /** 228*0e209d39SAndroid Build Coastguard Worker * Currency format with a currency symbol given CASH usage, e.g., 229*0e209d39SAndroid Build Coastguard Worker * "NT$3" instead of "NT$3.23". 230*0e209d39SAndroid Build Coastguard Worker * @stable ICU 54 231*0e209d39SAndroid Build Coastguard Worker */ 232*0e209d39SAndroid Build Coastguard Worker UNUM_CASH_CURRENCY=13, 233*0e209d39SAndroid Build Coastguard Worker /** 234*0e209d39SAndroid Build Coastguard Worker * Decimal format expressed using compact notation 235*0e209d39SAndroid Build Coastguard Worker * (short form, corresponds to UNumberCompactStyle=UNUM_SHORT) 236*0e209d39SAndroid Build Coastguard Worker * e.g. "23K", "45B" 237*0e209d39SAndroid Build Coastguard Worker * @stable ICU 56 238*0e209d39SAndroid Build Coastguard Worker */ 239*0e209d39SAndroid Build Coastguard Worker UNUM_DECIMAL_COMPACT_SHORT=14, 240*0e209d39SAndroid Build Coastguard Worker /** 241*0e209d39SAndroid Build Coastguard Worker * Decimal format expressed using compact notation 242*0e209d39SAndroid Build Coastguard Worker * (long form, corresponds to UNumberCompactStyle=UNUM_LONG) 243*0e209d39SAndroid Build Coastguard Worker * e.g. "23 thousand", "45 billion" 244*0e209d39SAndroid Build Coastguard Worker * @stable ICU 56 245*0e209d39SAndroid Build Coastguard Worker */ 246*0e209d39SAndroid Build Coastguard Worker UNUM_DECIMAL_COMPACT_LONG=15, 247*0e209d39SAndroid Build Coastguard Worker /** 248*0e209d39SAndroid Build Coastguard Worker * Currency format with a currency symbol, e.g., "$1.00", 249*0e209d39SAndroid Build Coastguard Worker * using non-accounting style for negative values (e.g. minus sign). 250*0e209d39SAndroid Build Coastguard Worker * Overrides any style specified using -cf- key in locale. 251*0e209d39SAndroid Build Coastguard Worker * @stable ICU 56 252*0e209d39SAndroid Build Coastguard Worker */ 253*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY_STANDARD=16, 254*0e209d39SAndroid Build Coastguard Worker 255*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 256*0e209d39SAndroid Build Coastguard Worker /** 257*0e209d39SAndroid Build Coastguard Worker * One more than the highest normal UNumberFormatStyle value. 258*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. 259*0e209d39SAndroid Build Coastguard Worker */ 260*0e209d39SAndroid Build Coastguard Worker UNUM_FORMAT_STYLE_COUNT=17, 261*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 262*0e209d39SAndroid Build Coastguard Worker 263*0e209d39SAndroid Build Coastguard Worker /** 264*0e209d39SAndroid Build Coastguard Worker * Default format 265*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 266*0e209d39SAndroid Build Coastguard Worker */ 267*0e209d39SAndroid Build Coastguard Worker UNUM_DEFAULT = UNUM_DECIMAL, 268*0e209d39SAndroid Build Coastguard Worker /** 269*0e209d39SAndroid Build Coastguard Worker * Alias for UNUM_PATTERN_DECIMAL 270*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 271*0e209d39SAndroid Build Coastguard Worker */ 272*0e209d39SAndroid Build Coastguard Worker UNUM_IGNORE = UNUM_PATTERN_DECIMAL 273*0e209d39SAndroid Build Coastguard Worker } UNumberFormatStyle; 274*0e209d39SAndroid Build Coastguard Worker 275*0e209d39SAndroid Build Coastguard Worker /** The possible number format pad positions. 276*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 277*0e209d39SAndroid Build Coastguard Worker */ 278*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberFormatPadPosition { 279*0e209d39SAndroid Build Coastguard Worker UNUM_PAD_BEFORE_PREFIX, 280*0e209d39SAndroid Build Coastguard Worker UNUM_PAD_AFTER_PREFIX, 281*0e209d39SAndroid Build Coastguard Worker UNUM_PAD_BEFORE_SUFFIX, 282*0e209d39SAndroid Build Coastguard Worker UNUM_PAD_AFTER_SUFFIX 283*0e209d39SAndroid Build Coastguard Worker } UNumberFormatPadPosition; 284*0e209d39SAndroid Build Coastguard Worker 285*0e209d39SAndroid Build Coastguard Worker /** 286*0e209d39SAndroid Build Coastguard Worker * Constants for specifying short or long format. 287*0e209d39SAndroid Build Coastguard Worker * @stable ICU 51 288*0e209d39SAndroid Build Coastguard Worker */ 289*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberCompactStyle { 290*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 51 */ 291*0e209d39SAndroid Build Coastguard Worker UNUM_SHORT, 292*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 51 */ 293*0e209d39SAndroid Build Coastguard Worker UNUM_LONG 294*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 51 */ 295*0e209d39SAndroid Build Coastguard Worker } UNumberCompactStyle; 296*0e209d39SAndroid Build Coastguard Worker 297*0e209d39SAndroid Build Coastguard Worker /** 298*0e209d39SAndroid Build Coastguard Worker * Constants for specifying currency spacing 299*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.8 300*0e209d39SAndroid Build Coastguard Worker */ 301*0e209d39SAndroid Build Coastguard Worker enum UCurrencySpacing { 302*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 4.8 */ 303*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY_MATCH, 304*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 4.8 */ 305*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY_SURROUNDING_MATCH, 306*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 4.8 */ 307*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY_INSERT, 308*0e209d39SAndroid Build Coastguard Worker 309*0e209d39SAndroid Build Coastguard Worker /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, 310*0e209d39SAndroid Build Coastguard Worker * it is needed for layout of DecimalFormatSymbols object. */ 311*0e209d39SAndroid Build Coastguard Worker #ifndef U_FORCE_HIDE_DEPRECATED_API 312*0e209d39SAndroid Build Coastguard Worker /** 313*0e209d39SAndroid Build Coastguard Worker * One more than the highest normal UCurrencySpacing value. 314*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. 315*0e209d39SAndroid Build Coastguard Worker */ 316*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY_SPACING_COUNT 317*0e209d39SAndroid Build Coastguard Worker #endif // U_FORCE_HIDE_DEPRECATED_API 318*0e209d39SAndroid Build Coastguard Worker }; 319*0e209d39SAndroid Build Coastguard Worker typedef enum UCurrencySpacing UCurrencySpacing; /**< @stable ICU 4.8 */ 320*0e209d39SAndroid Build Coastguard Worker 321*0e209d39SAndroid Build Coastguard Worker 322*0e209d39SAndroid Build Coastguard Worker /** 323*0e209d39SAndroid Build Coastguard Worker * FieldPosition and UFieldPosition selectors for format fields 324*0e209d39SAndroid Build Coastguard Worker * defined by NumberFormat and UNumberFormat. 325*0e209d39SAndroid Build Coastguard Worker * @stable ICU 49 326*0e209d39SAndroid Build Coastguard Worker */ 327*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberFormatFields { 328*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 49 */ 329*0e209d39SAndroid Build Coastguard Worker UNUM_INTEGER_FIELD, 330*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 49 */ 331*0e209d39SAndroid Build Coastguard Worker UNUM_FRACTION_FIELD, 332*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 49 */ 333*0e209d39SAndroid Build Coastguard Worker UNUM_DECIMAL_SEPARATOR_FIELD, 334*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 49 */ 335*0e209d39SAndroid Build Coastguard Worker UNUM_EXPONENT_SYMBOL_FIELD, 336*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 49 */ 337*0e209d39SAndroid Build Coastguard Worker UNUM_EXPONENT_SIGN_FIELD, 338*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 49 */ 339*0e209d39SAndroid Build Coastguard Worker UNUM_EXPONENT_FIELD, 340*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 49 */ 341*0e209d39SAndroid Build Coastguard Worker UNUM_GROUPING_SEPARATOR_FIELD, 342*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 49 */ 343*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY_FIELD, 344*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 49 */ 345*0e209d39SAndroid Build Coastguard Worker UNUM_PERCENT_FIELD, 346*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 49 */ 347*0e209d39SAndroid Build Coastguard Worker UNUM_PERMILL_FIELD, 348*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 49 */ 349*0e209d39SAndroid Build Coastguard Worker UNUM_SIGN_FIELD, 350*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 64 */ 351*0e209d39SAndroid Build Coastguard Worker UNUM_MEASURE_UNIT_FIELD, 352*0e209d39SAndroid Build Coastguard Worker /** @stable ICU 64 */ 353*0e209d39SAndroid Build Coastguard Worker UNUM_COMPACT_FIELD, 354*0e209d39SAndroid Build Coastguard Worker /** 355*0e209d39SAndroid Build Coastguard Worker * Approximately sign. In ICU 70, this was categorized under the generic SIGN field. 356*0e209d39SAndroid Build Coastguard Worker * @stable ICU 71 357*0e209d39SAndroid Build Coastguard Worker */ 358*0e209d39SAndroid Build Coastguard Worker UNUM_APPROXIMATELY_SIGN_FIELD, 359*0e209d39SAndroid Build Coastguard Worker 360*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 361*0e209d39SAndroid Build Coastguard Worker /** 362*0e209d39SAndroid Build Coastguard Worker * One more than the highest normal UNumberFormatFields value. 363*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. 364*0e209d39SAndroid Build Coastguard Worker */ 365*0e209d39SAndroid Build Coastguard Worker UNUM_FIELD_COUNT 366*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 367*0e209d39SAndroid Build Coastguard Worker } UNumberFormatFields; 368*0e209d39SAndroid Build Coastguard Worker 369*0e209d39SAndroid Build Coastguard Worker 370*0e209d39SAndroid Build Coastguard Worker /** 371*0e209d39SAndroid Build Coastguard Worker * Selectors with special numeric values to use locale default minimum grouping 372*0e209d39SAndroid Build Coastguard Worker * digits for the DecimalFormat/UNumberFormat setMinimumGroupingDigits method. 373*0e209d39SAndroid Build Coastguard Worker * Do not use these constants with the [U]NumberFormatter API. 374*0e209d39SAndroid Build Coastguard Worker * 375*0e209d39SAndroid Build Coastguard Worker * @stable ICU 68 376*0e209d39SAndroid Build Coastguard Worker */ 377*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberFormatMinimumGroupingDigits { 378*0e209d39SAndroid Build Coastguard Worker /** 379*0e209d39SAndroid Build Coastguard Worker * Display grouping using the default strategy for all locales. 380*0e209d39SAndroid Build Coastguard Worker * @stable ICU 68 381*0e209d39SAndroid Build Coastguard Worker */ 382*0e209d39SAndroid Build Coastguard Worker UNUM_MINIMUM_GROUPING_DIGITS_AUTO = -2, 383*0e209d39SAndroid Build Coastguard Worker /** 384*0e209d39SAndroid Build Coastguard Worker * Display grouping using locale defaults, except do not show grouping on 385*0e209d39SAndroid Build Coastguard Worker * values smaller than 10000 (such that there is a minimum of two digits 386*0e209d39SAndroid Build Coastguard Worker * before the first separator). 387*0e209d39SAndroid Build Coastguard Worker * @stable ICU 68 388*0e209d39SAndroid Build Coastguard Worker */ 389*0e209d39SAndroid Build Coastguard Worker UNUM_MINIMUM_GROUPING_DIGITS_MIN2 = -3, 390*0e209d39SAndroid Build Coastguard Worker } UNumberFormatMinimumGroupingDigits; 391*0e209d39SAndroid Build Coastguard Worker 392*0e209d39SAndroid Build Coastguard Worker /** 393*0e209d39SAndroid Build Coastguard Worker * Create and return a new UNumberFormat for formatting and parsing 394*0e209d39SAndroid Build Coastguard Worker * numbers. A UNumberFormat may be used to format numbers by calling 395*0e209d39SAndroid Build Coastguard Worker * {@link #unum_format }, and to parse numbers by calling {@link #unum_parse }. 396*0e209d39SAndroid Build Coastguard Worker * The caller must call {@link #unum_close } when done to release resources 397*0e209d39SAndroid Build Coastguard Worker * used by this object. 398*0e209d39SAndroid Build Coastguard Worker * @param style The type of number format to open: one of 399*0e209d39SAndroid Build Coastguard Worker * UNUM_DECIMAL, UNUM_CURRENCY, UNUM_PERCENT, UNUM_SCIENTIFIC, 400*0e209d39SAndroid Build Coastguard Worker * UNUM_CURRENCY_ISO, UNUM_CURRENCY_PLURAL, UNUM_SPELLOUT, 401*0e209d39SAndroid Build Coastguard Worker * UNUM_ORDINAL, UNUM_DURATION, UNUM_NUMBERING_SYSTEM, 402*0e209d39SAndroid Build Coastguard Worker * UNUM_PATTERN_DECIMAL, UNUM_PATTERN_RULEBASED, or UNUM_DEFAULT. 403*0e209d39SAndroid Build Coastguard Worker * If UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED is passed then the 404*0e209d39SAndroid Build Coastguard Worker * number format is opened using the given pattern, which must conform 405*0e209d39SAndroid Build Coastguard Worker * to the syntax described in DecimalFormat or RuleBasedNumberFormat, 406*0e209d39SAndroid Build Coastguard Worker * respectively. 407*0e209d39SAndroid Build Coastguard Worker * 408*0e209d39SAndroid Build Coastguard Worker * <p><strong>NOTE::</strong> New users with are strongly encouraged to 409*0e209d39SAndroid Build Coastguard Worker * use unumf_openForSkeletonAndLocale instead of unum_open. 410*0e209d39SAndroid Build Coastguard Worker * 411*0e209d39SAndroid Build Coastguard Worker * @param pattern A pattern specifying the format to use. 412*0e209d39SAndroid Build Coastguard Worker * This parameter is ignored unless the style is 413*0e209d39SAndroid Build Coastguard Worker * UNUM_PATTERN_DECIMAL or UNUM_PATTERN_RULEBASED. 414*0e209d39SAndroid Build Coastguard Worker * @param patternLength The number of characters in the pattern, or -1 415*0e209d39SAndroid Build Coastguard Worker * if null-terminated. This parameter is ignored unless the style is 416*0e209d39SAndroid Build Coastguard Worker * UNUM_PATTERN. 417*0e209d39SAndroid Build Coastguard Worker * @param locale A locale identifier to use to determine formatting 418*0e209d39SAndroid Build Coastguard Worker * and parsing conventions, or NULL to use the default locale. 419*0e209d39SAndroid Build Coastguard Worker * @param parseErr A pointer to a UParseError struct to receive the 420*0e209d39SAndroid Build Coastguard Worker * details of any parsing errors, or NULL if no parsing error details 421*0e209d39SAndroid Build Coastguard Worker * are desired. 422*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an input-output UErrorCode. 423*0e209d39SAndroid Build Coastguard Worker * @return A pointer to a newly created UNumberFormat, or NULL if an 424*0e209d39SAndroid Build Coastguard Worker * error occurred. 425*0e209d39SAndroid Build Coastguard Worker * @see unum_close 426*0e209d39SAndroid Build Coastguard Worker * @see DecimalFormat 427*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 428*0e209d39SAndroid Build Coastguard Worker */ 429*0e209d39SAndroid Build Coastguard Worker U_CAPI UNumberFormat* U_EXPORT2 430*0e209d39SAndroid Build Coastguard Worker unum_open( UNumberFormatStyle style, 431*0e209d39SAndroid Build Coastguard Worker const UChar* pattern, 432*0e209d39SAndroid Build Coastguard Worker int32_t patternLength, 433*0e209d39SAndroid Build Coastguard Worker const char* locale, 434*0e209d39SAndroid Build Coastguard Worker UParseError* parseErr, 435*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 436*0e209d39SAndroid Build Coastguard Worker 437*0e209d39SAndroid Build Coastguard Worker 438*0e209d39SAndroid Build Coastguard Worker /** 439*0e209d39SAndroid Build Coastguard Worker * Close a UNumberFormat. 440*0e209d39SAndroid Build Coastguard Worker * Once closed, a UNumberFormat may no longer be used. 441*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to close. 442*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 443*0e209d39SAndroid Build Coastguard Worker */ 444*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 445*0e209d39SAndroid Build Coastguard Worker unum_close(UNumberFormat* fmt); 446*0e209d39SAndroid Build Coastguard Worker 447*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 448*0e209d39SAndroid Build Coastguard Worker 449*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 450*0e209d39SAndroid Build Coastguard Worker 451*0e209d39SAndroid Build Coastguard Worker /** 452*0e209d39SAndroid Build Coastguard Worker * \class LocalUNumberFormatPointer 453*0e209d39SAndroid Build Coastguard Worker * "Smart pointer" class, closes a UNumberFormat via unum_close(). 454*0e209d39SAndroid Build Coastguard Worker * For most methods see the LocalPointerBase base class. 455*0e209d39SAndroid Build Coastguard Worker * 456*0e209d39SAndroid Build Coastguard Worker * @see LocalPointerBase 457*0e209d39SAndroid Build Coastguard Worker * @see LocalPointer 458*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.4 459*0e209d39SAndroid Build Coastguard Worker */ 460*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatPointer, UNumberFormat, unum_close); 461*0e209d39SAndroid Build Coastguard Worker 462*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 463*0e209d39SAndroid Build Coastguard Worker 464*0e209d39SAndroid Build Coastguard Worker #endif 465*0e209d39SAndroid Build Coastguard Worker 466*0e209d39SAndroid Build Coastguard Worker /** 467*0e209d39SAndroid Build Coastguard Worker * Open a copy of a UNumberFormat. 468*0e209d39SAndroid Build Coastguard Worker * This function performs a deep copy. 469*0e209d39SAndroid Build Coastguard Worker * @param fmt The format to copy 470*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors. 471*0e209d39SAndroid Build Coastguard Worker * @return A pointer to a UNumberFormat identical to fmt. 472*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 473*0e209d39SAndroid Build Coastguard Worker */ 474*0e209d39SAndroid Build Coastguard Worker U_CAPI UNumberFormat* U_EXPORT2 475*0e209d39SAndroid Build Coastguard Worker unum_clone(const UNumberFormat *fmt, 476*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 477*0e209d39SAndroid Build Coastguard Worker 478*0e209d39SAndroid Build Coastguard Worker /** 479*0e209d39SAndroid Build Coastguard Worker * Format an integer using a UNumberFormat. 480*0e209d39SAndroid Build Coastguard Worker * The integer will be formatted according to the UNumberFormat's locale. 481*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to use. 482*0e209d39SAndroid Build Coastguard Worker * @param number The number to format. 483*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the NULL-terminated formatted number. If 484*0e209d39SAndroid Build Coastguard Worker * the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) 485*0e209d39SAndroid Build Coastguard Worker * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number 486*0e209d39SAndroid Build Coastguard Worker * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR. 487*0e209d39SAndroid Build Coastguard Worker * @param resultLength The maximum size of result. 488*0e209d39SAndroid Build Coastguard Worker * @param pos A pointer to a UFieldPosition. On input, position->field 489*0e209d39SAndroid Build Coastguard Worker * is read. On output, position->beginIndex and position->endIndex indicate 490*0e209d39SAndroid Build Coastguard Worker * the beginning and ending indices of field number position->field, if such 491*0e209d39SAndroid Build Coastguard Worker * a field exists. This parameter may be NULL, in which case no field 492*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 493*0e209d39SAndroid Build Coastguard Worker * @return The total buffer size needed; if greater than resultLength, the output was truncated. 494*0e209d39SAndroid Build Coastguard Worker * @see unum_formatInt64 495*0e209d39SAndroid Build Coastguard Worker * @see unum_formatDouble 496*0e209d39SAndroid Build Coastguard Worker * @see unum_parse 497*0e209d39SAndroid Build Coastguard Worker * @see unum_parseInt64 498*0e209d39SAndroid Build Coastguard Worker * @see unum_parseDouble 499*0e209d39SAndroid Build Coastguard Worker * @see UFieldPosition 500*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 501*0e209d39SAndroid Build Coastguard Worker */ 502*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 503*0e209d39SAndroid Build Coastguard Worker unum_format( const UNumberFormat* fmt, 504*0e209d39SAndroid Build Coastguard Worker int32_t number, 505*0e209d39SAndroid Build Coastguard Worker UChar* result, 506*0e209d39SAndroid Build Coastguard Worker int32_t resultLength, 507*0e209d39SAndroid Build Coastguard Worker UFieldPosition *pos, 508*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 509*0e209d39SAndroid Build Coastguard Worker 510*0e209d39SAndroid Build Coastguard Worker /** 511*0e209d39SAndroid Build Coastguard Worker * Format an int64 using a UNumberFormat. 512*0e209d39SAndroid Build Coastguard Worker * The int64 will be formatted according to the UNumberFormat's locale. 513*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to use. 514*0e209d39SAndroid Build Coastguard Worker * @param number The number to format. 515*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the NULL-terminated formatted number. If 516*0e209d39SAndroid Build Coastguard Worker * the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) 517*0e209d39SAndroid Build Coastguard Worker * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number 518*0e209d39SAndroid Build Coastguard Worker * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR. 519*0e209d39SAndroid Build Coastguard Worker * @param resultLength The maximum size of result. 520*0e209d39SAndroid Build Coastguard Worker * @param pos A pointer to a UFieldPosition. On input, position->field 521*0e209d39SAndroid Build Coastguard Worker * is read. On output, position->beginIndex and position->endIndex indicate 522*0e209d39SAndroid Build Coastguard Worker * the beginning and ending indices of field number position->field, if such 523*0e209d39SAndroid Build Coastguard Worker * a field exists. This parameter may be NULL, in which case no field 524*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 525*0e209d39SAndroid Build Coastguard Worker * @return The total buffer size needed; if greater than resultLength, the output was truncated. 526*0e209d39SAndroid Build Coastguard Worker * @see unum_format 527*0e209d39SAndroid Build Coastguard Worker * @see unum_formatDouble 528*0e209d39SAndroid Build Coastguard Worker * @see unum_parse 529*0e209d39SAndroid Build Coastguard Worker * @see unum_parseInt64 530*0e209d39SAndroid Build Coastguard Worker * @see unum_parseDouble 531*0e209d39SAndroid Build Coastguard Worker * @see UFieldPosition 532*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 533*0e209d39SAndroid Build Coastguard Worker */ 534*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 535*0e209d39SAndroid Build Coastguard Worker unum_formatInt64(const UNumberFormat *fmt, 536*0e209d39SAndroid Build Coastguard Worker int64_t number, 537*0e209d39SAndroid Build Coastguard Worker UChar* result, 538*0e209d39SAndroid Build Coastguard Worker int32_t resultLength, 539*0e209d39SAndroid Build Coastguard Worker UFieldPosition *pos, 540*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 541*0e209d39SAndroid Build Coastguard Worker 542*0e209d39SAndroid Build Coastguard Worker /** 543*0e209d39SAndroid Build Coastguard Worker * Format a double using a UNumberFormat. 544*0e209d39SAndroid Build Coastguard Worker * The double will be formatted according to the UNumberFormat's locale. 545*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to use. 546*0e209d39SAndroid Build Coastguard Worker * @param number The number to format. 547*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the NULL-terminated formatted number. If 548*0e209d39SAndroid Build Coastguard Worker * the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) 549*0e209d39SAndroid Build Coastguard Worker * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number 550*0e209d39SAndroid Build Coastguard Worker * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR. 551*0e209d39SAndroid Build Coastguard Worker * @param resultLength The maximum size of result. 552*0e209d39SAndroid Build Coastguard Worker * @param pos A pointer to a UFieldPosition. On input, position->field 553*0e209d39SAndroid Build Coastguard Worker * is read. On output, position->beginIndex and position->endIndex indicate 554*0e209d39SAndroid Build Coastguard Worker * the beginning and ending indices of field number position->field, if such 555*0e209d39SAndroid Build Coastguard Worker * a field exists. This parameter may be NULL, in which case no field 556*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 557*0e209d39SAndroid Build Coastguard Worker * @return The total buffer size needed; if greater than resultLength, the output was truncated. 558*0e209d39SAndroid Build Coastguard Worker * @see unum_format 559*0e209d39SAndroid Build Coastguard Worker * @see unum_formatInt64 560*0e209d39SAndroid Build Coastguard Worker * @see unum_parse 561*0e209d39SAndroid Build Coastguard Worker * @see unum_parseInt64 562*0e209d39SAndroid Build Coastguard Worker * @see unum_parseDouble 563*0e209d39SAndroid Build Coastguard Worker * @see UFieldPosition 564*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 565*0e209d39SAndroid Build Coastguard Worker */ 566*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 567*0e209d39SAndroid Build Coastguard Worker unum_formatDouble( const UNumberFormat* fmt, 568*0e209d39SAndroid Build Coastguard Worker double number, 569*0e209d39SAndroid Build Coastguard Worker UChar* result, 570*0e209d39SAndroid Build Coastguard Worker int32_t resultLength, 571*0e209d39SAndroid Build Coastguard Worker UFieldPosition *pos, /* 0 if ignore */ 572*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 573*0e209d39SAndroid Build Coastguard Worker 574*0e209d39SAndroid Build Coastguard Worker /** 575*0e209d39SAndroid Build Coastguard Worker * Format a double using a UNumberFormat according to the UNumberFormat's locale, 576*0e209d39SAndroid Build Coastguard Worker * and initialize a UFieldPositionIterator that enumerates the subcomponents of 577*0e209d39SAndroid Build Coastguard Worker * the resulting string. 578*0e209d39SAndroid Build Coastguard Worker * 579*0e209d39SAndroid Build Coastguard Worker * @param format 580*0e209d39SAndroid Build Coastguard Worker * The formatter to use. 581*0e209d39SAndroid Build Coastguard Worker * @param number 582*0e209d39SAndroid Build Coastguard Worker * The number to format. 583*0e209d39SAndroid Build Coastguard Worker * @param result 584*0e209d39SAndroid Build Coastguard Worker * A pointer to a buffer to receive the NULL-terminated formatted 585*0e209d39SAndroid Build Coastguard Worker * number. If the formatted number fits into dest but cannot be 586*0e209d39SAndroid Build Coastguard Worker * NULL-terminated (length == resultLength) then the error code is set 587*0e209d39SAndroid Build Coastguard Worker * to U_STRING_NOT_TERMINATED_WARNING. If the formatted number doesn't 588*0e209d39SAndroid Build Coastguard Worker * fit into result then the error code is set to 589*0e209d39SAndroid Build Coastguard Worker * U_BUFFER_OVERFLOW_ERROR. 590*0e209d39SAndroid Build Coastguard Worker * @param resultLength 591*0e209d39SAndroid Build Coastguard Worker * The maximum size of result. 592*0e209d39SAndroid Build Coastguard Worker * @param fpositer 593*0e209d39SAndroid Build Coastguard Worker * A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open} 594*0e209d39SAndroid Build Coastguard Worker * (may be NULL if field position information is not needed, but in this 595*0e209d39SAndroid Build Coastguard Worker * case it's preferable to use {@link #unum_formatDouble}). Iteration 596*0e209d39SAndroid Build Coastguard Worker * information already present in the UFieldPositionIterator is deleted, 597*0e209d39SAndroid Build Coastguard Worker * and the iterator is reset to apply to the fields in the formatted 598*0e209d39SAndroid Build Coastguard Worker * string created by this function call. The field values and indexes 599*0e209d39SAndroid Build Coastguard Worker * returned by {@link #ufieldpositer_next} represent fields denoted by 600*0e209d39SAndroid Build Coastguard Worker * the UNumberFormatFields enum. Fields are not returned in a guaranteed 601*0e209d39SAndroid Build Coastguard Worker * order. Fields cannot overlap, but they may nest. For example, 1234 602*0e209d39SAndroid Build Coastguard Worker * could format as "1,234" which might consist of a grouping separator 603*0e209d39SAndroid Build Coastguard Worker * field for ',' and an integer field encompassing the entire string. 604*0e209d39SAndroid Build Coastguard Worker * @param status 605*0e209d39SAndroid Build Coastguard Worker * A pointer to an UErrorCode to receive any errors 606*0e209d39SAndroid Build Coastguard Worker * @return 607*0e209d39SAndroid Build Coastguard Worker * The total buffer size needed; if greater than resultLength, the 608*0e209d39SAndroid Build Coastguard Worker * output was truncated. 609*0e209d39SAndroid Build Coastguard Worker * @see unum_formatDouble 610*0e209d39SAndroid Build Coastguard Worker * @see unum_parse 611*0e209d39SAndroid Build Coastguard Worker * @see unum_parseDouble 612*0e209d39SAndroid Build Coastguard Worker * @see UFieldPositionIterator 613*0e209d39SAndroid Build Coastguard Worker * @see UNumberFormatFields 614*0e209d39SAndroid Build Coastguard Worker * @stable ICU 59 615*0e209d39SAndroid Build Coastguard Worker */ 616*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 617*0e209d39SAndroid Build Coastguard Worker unum_formatDoubleForFields(const UNumberFormat* format, 618*0e209d39SAndroid Build Coastguard Worker double number, 619*0e209d39SAndroid Build Coastguard Worker UChar* result, 620*0e209d39SAndroid Build Coastguard Worker int32_t resultLength, 621*0e209d39SAndroid Build Coastguard Worker UFieldPositionIterator* fpositer, 622*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 623*0e209d39SAndroid Build Coastguard Worker 624*0e209d39SAndroid Build Coastguard Worker 625*0e209d39SAndroid Build Coastguard Worker /** 626*0e209d39SAndroid Build Coastguard Worker * Format a decimal number using a UNumberFormat. 627*0e209d39SAndroid Build Coastguard Worker * The number will be formatted according to the UNumberFormat's locale. 628*0e209d39SAndroid Build Coastguard Worker * The syntax of the input number is a "numeric string" 629*0e209d39SAndroid Build Coastguard Worker * as defined in the Decimal Arithmetic Specification, available at 630*0e209d39SAndroid Build Coastguard Worker * http://speleotrove.com/decimal 631*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to use. 632*0e209d39SAndroid Build Coastguard Worker * @param number The number to format. 633*0e209d39SAndroid Build Coastguard Worker * @param length The length of the input number, or -1 if the input is nul-terminated. 634*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the NULL-terminated formatted number. If 635*0e209d39SAndroid Build Coastguard Worker * the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) 636*0e209d39SAndroid Build Coastguard Worker * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number 637*0e209d39SAndroid Build Coastguard Worker * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR. 638*0e209d39SAndroid Build Coastguard Worker * @param resultLength The maximum size of result. 639*0e209d39SAndroid Build Coastguard Worker * @param pos A pointer to a UFieldPosition. On input, position->field 640*0e209d39SAndroid Build Coastguard Worker * is read. On output, position->beginIndex and position->endIndex indicate 641*0e209d39SAndroid Build Coastguard Worker * the beginning and ending indices of field number position->field, if such 642*0e209d39SAndroid Build Coastguard Worker * a field exists. This parameter may be NULL, in which case it is ignored. 643*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 644*0e209d39SAndroid Build Coastguard Worker * @return The total buffer size needed; if greater than resultLength, the output was truncated. 645*0e209d39SAndroid Build Coastguard Worker * @see unum_format 646*0e209d39SAndroid Build Coastguard Worker * @see unum_formatInt64 647*0e209d39SAndroid Build Coastguard Worker * @see unum_parse 648*0e209d39SAndroid Build Coastguard Worker * @see unum_parseInt64 649*0e209d39SAndroid Build Coastguard Worker * @see unum_parseDouble 650*0e209d39SAndroid Build Coastguard Worker * @see UFieldPosition 651*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.4 652*0e209d39SAndroid Build Coastguard Worker */ 653*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 654*0e209d39SAndroid Build Coastguard Worker unum_formatDecimal( const UNumberFormat* fmt, 655*0e209d39SAndroid Build Coastguard Worker const char * number, 656*0e209d39SAndroid Build Coastguard Worker int32_t length, 657*0e209d39SAndroid Build Coastguard Worker UChar* result, 658*0e209d39SAndroid Build Coastguard Worker int32_t resultLength, 659*0e209d39SAndroid Build Coastguard Worker UFieldPosition *pos, /* 0 if ignore */ 660*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 661*0e209d39SAndroid Build Coastguard Worker 662*0e209d39SAndroid Build Coastguard Worker /** 663*0e209d39SAndroid Build Coastguard Worker * Format a double currency amount using a UNumberFormat. 664*0e209d39SAndroid Build Coastguard Worker * The double will be formatted according to the UNumberFormat's locale. 665*0e209d39SAndroid Build Coastguard Worker * 666*0e209d39SAndroid Build Coastguard Worker * To format an exact decimal value with a currency, use 667*0e209d39SAndroid Build Coastguard Worker * `unum_setTextAttribute(UNUM_CURRENCY_CODE, ...)` followed by unum_formatDecimal. 668*0e209d39SAndroid Build Coastguard Worker * Your UNumberFormat must be created with the UNUM_CURRENCY style. Alternatively, 669*0e209d39SAndroid Build Coastguard Worker * consider using unumf_openForSkeletonAndLocale. 670*0e209d39SAndroid Build Coastguard Worker * 671*0e209d39SAndroid Build Coastguard Worker * @param fmt the formatter to use 672*0e209d39SAndroid Build Coastguard Worker * @param number the number to format 673*0e209d39SAndroid Build Coastguard Worker * @param currency the 3-letter null-terminated ISO 4217 currency code 674*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the NULL-terminated formatted number. If 675*0e209d39SAndroid Build Coastguard Worker * the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) 676*0e209d39SAndroid Build Coastguard Worker * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number 677*0e209d39SAndroid Build Coastguard Worker * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR. 678*0e209d39SAndroid Build Coastguard Worker * @param resultLength the maximum number of UChars to write to result 679*0e209d39SAndroid Build Coastguard Worker * @param pos a pointer to a UFieldPosition. On input, 680*0e209d39SAndroid Build Coastguard Worker * position->field is read. On output, position->beginIndex and 681*0e209d39SAndroid Build Coastguard Worker * position->endIndex indicate the beginning and ending indices of 682*0e209d39SAndroid Build Coastguard Worker * field number position->field, if such a field exists. This 683*0e209d39SAndroid Build Coastguard Worker * parameter may be NULL, in which case it is ignored. 684*0e209d39SAndroid Build Coastguard Worker * @param status a pointer to an input-output UErrorCode 685*0e209d39SAndroid Build Coastguard Worker * @return the total buffer size needed; if greater than resultLength, 686*0e209d39SAndroid Build Coastguard Worker * the output was truncated. 687*0e209d39SAndroid Build Coastguard Worker * @see unum_formatDouble 688*0e209d39SAndroid Build Coastguard Worker * @see unum_parseDoubleCurrency 689*0e209d39SAndroid Build Coastguard Worker * @see UFieldPosition 690*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 691*0e209d39SAndroid Build Coastguard Worker */ 692*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 693*0e209d39SAndroid Build Coastguard Worker unum_formatDoubleCurrency(const UNumberFormat* fmt, 694*0e209d39SAndroid Build Coastguard Worker double number, 695*0e209d39SAndroid Build Coastguard Worker UChar* currency, 696*0e209d39SAndroid Build Coastguard Worker UChar* result, 697*0e209d39SAndroid Build Coastguard Worker int32_t resultLength, 698*0e209d39SAndroid Build Coastguard Worker UFieldPosition* pos, 699*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 700*0e209d39SAndroid Build Coastguard Worker 701*0e209d39SAndroid Build Coastguard Worker /** 702*0e209d39SAndroid Build Coastguard Worker * Format a UFormattable into a string. 703*0e209d39SAndroid Build Coastguard Worker * @param fmt the formatter to use 704*0e209d39SAndroid Build Coastguard Worker * @param number the number to format, as a UFormattable 705*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the NULL-terminated formatted number. If 706*0e209d39SAndroid Build Coastguard Worker * the formatted number fits into dest but cannot be NULL-terminated (length == resultLength) 707*0e209d39SAndroid Build Coastguard Worker * then the error code is set to U_STRING_NOT_TERMINATED_WARNING. If the formatted number 708*0e209d39SAndroid Build Coastguard Worker * doesn't fit into result then the error code is set to U_BUFFER_OVERFLOW_ERROR. 709*0e209d39SAndroid Build Coastguard Worker * @param resultLength the maximum number of UChars to write to result 710*0e209d39SAndroid Build Coastguard Worker * @param pos a pointer to a UFieldPosition. On input, 711*0e209d39SAndroid Build Coastguard Worker * position->field is read. On output, position->beginIndex and 712*0e209d39SAndroid Build Coastguard Worker * position->endIndex indicate the beginning and ending indices of 713*0e209d39SAndroid Build Coastguard Worker * field number position->field, if such a field exists. This 714*0e209d39SAndroid Build Coastguard Worker * parameter may be NULL, in which case it is ignored. 715*0e209d39SAndroid Build Coastguard Worker * @param status a pointer to an input-output UErrorCode 716*0e209d39SAndroid Build Coastguard Worker * @return the total buffer size needed; if greater than resultLength, 717*0e209d39SAndroid Build Coastguard Worker * the output was truncated. Will return 0 on error. 718*0e209d39SAndroid Build Coastguard Worker * @see unum_parseToUFormattable 719*0e209d39SAndroid Build Coastguard Worker * @stable ICU 52 720*0e209d39SAndroid Build Coastguard Worker */ 721*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 722*0e209d39SAndroid Build Coastguard Worker unum_formatUFormattable(const UNumberFormat* fmt, 723*0e209d39SAndroid Build Coastguard Worker const UFormattable *number, 724*0e209d39SAndroid Build Coastguard Worker UChar *result, 725*0e209d39SAndroid Build Coastguard Worker int32_t resultLength, 726*0e209d39SAndroid Build Coastguard Worker UFieldPosition *pos, 727*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 728*0e209d39SAndroid Build Coastguard Worker 729*0e209d39SAndroid Build Coastguard Worker /** 730*0e209d39SAndroid Build Coastguard Worker * Parse a string into an integer using a UNumberFormat. 731*0e209d39SAndroid Build Coastguard Worker * The string will be parsed according to the UNumberFormat's locale. 732*0e209d39SAndroid Build Coastguard Worker * Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT 733*0e209d39SAndroid Build Coastguard Worker * and UNUM_DECIMAL_COMPACT_LONG. 734*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to use. 735*0e209d39SAndroid Build Coastguard Worker * @param text The text to parse. 736*0e209d39SAndroid Build Coastguard Worker * @param textLength The length of text, or -1 if null-terminated. 737*0e209d39SAndroid Build Coastguard Worker * @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which 738*0e209d39SAndroid Build Coastguard Worker * to begin parsing. If not NULL, on output the offset at which parsing ended. 739*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 740*0e209d39SAndroid Build Coastguard Worker * @return The value of the parsed integer 741*0e209d39SAndroid Build Coastguard Worker * @see unum_parseInt64 742*0e209d39SAndroid Build Coastguard Worker * @see unum_parseDouble 743*0e209d39SAndroid Build Coastguard Worker * @see unum_format 744*0e209d39SAndroid Build Coastguard Worker * @see unum_formatInt64 745*0e209d39SAndroid Build Coastguard Worker * @see unum_formatDouble 746*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 747*0e209d39SAndroid Build Coastguard Worker */ 748*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 749*0e209d39SAndroid Build Coastguard Worker unum_parse( const UNumberFormat* fmt, 750*0e209d39SAndroid Build Coastguard Worker const UChar* text, 751*0e209d39SAndroid Build Coastguard Worker int32_t textLength, 752*0e209d39SAndroid Build Coastguard Worker int32_t *parsePos /* 0 = start */, 753*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 754*0e209d39SAndroid Build Coastguard Worker 755*0e209d39SAndroid Build Coastguard Worker /** 756*0e209d39SAndroid Build Coastguard Worker * Parse a string into an int64 using a UNumberFormat. 757*0e209d39SAndroid Build Coastguard Worker * The string will be parsed according to the UNumberFormat's locale. 758*0e209d39SAndroid Build Coastguard Worker * Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT 759*0e209d39SAndroid Build Coastguard Worker * and UNUM_DECIMAL_COMPACT_LONG. 760*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to use. 761*0e209d39SAndroid Build Coastguard Worker * @param text The text to parse. 762*0e209d39SAndroid Build Coastguard Worker * @param textLength The length of text, or -1 if null-terminated. 763*0e209d39SAndroid Build Coastguard Worker * @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which 764*0e209d39SAndroid Build Coastguard Worker * to begin parsing. If not NULL, on output the offset at which parsing ended. 765*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 766*0e209d39SAndroid Build Coastguard Worker * @return The value of the parsed integer 767*0e209d39SAndroid Build Coastguard Worker * @see unum_parse 768*0e209d39SAndroid Build Coastguard Worker * @see unum_parseDouble 769*0e209d39SAndroid Build Coastguard Worker * @see unum_format 770*0e209d39SAndroid Build Coastguard Worker * @see unum_formatInt64 771*0e209d39SAndroid Build Coastguard Worker * @see unum_formatDouble 772*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.8 773*0e209d39SAndroid Build Coastguard Worker */ 774*0e209d39SAndroid Build Coastguard Worker U_CAPI int64_t U_EXPORT2 775*0e209d39SAndroid Build Coastguard Worker unum_parseInt64(const UNumberFormat* fmt, 776*0e209d39SAndroid Build Coastguard Worker const UChar* text, 777*0e209d39SAndroid Build Coastguard Worker int32_t textLength, 778*0e209d39SAndroid Build Coastguard Worker int32_t *parsePos /* 0 = start */, 779*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 780*0e209d39SAndroid Build Coastguard Worker 781*0e209d39SAndroid Build Coastguard Worker /** 782*0e209d39SAndroid Build Coastguard Worker * Parse a string into a double using a UNumberFormat. 783*0e209d39SAndroid Build Coastguard Worker * The string will be parsed according to the UNumberFormat's locale. 784*0e209d39SAndroid Build Coastguard Worker * Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT 785*0e209d39SAndroid Build Coastguard Worker * and UNUM_DECIMAL_COMPACT_LONG. 786*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to use. 787*0e209d39SAndroid Build Coastguard Worker * @param text The text to parse. 788*0e209d39SAndroid Build Coastguard Worker * @param textLength The length of text, or -1 if null-terminated. 789*0e209d39SAndroid Build Coastguard Worker * @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which 790*0e209d39SAndroid Build Coastguard Worker * to begin parsing. If not NULL, on output the offset at which parsing ended. 791*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 792*0e209d39SAndroid Build Coastguard Worker * @return The value of the parsed double 793*0e209d39SAndroid Build Coastguard Worker * @see unum_parse 794*0e209d39SAndroid Build Coastguard Worker * @see unum_parseInt64 795*0e209d39SAndroid Build Coastguard Worker * @see unum_format 796*0e209d39SAndroid Build Coastguard Worker * @see unum_formatInt64 797*0e209d39SAndroid Build Coastguard Worker * @see unum_formatDouble 798*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 799*0e209d39SAndroid Build Coastguard Worker */ 800*0e209d39SAndroid Build Coastguard Worker U_CAPI double U_EXPORT2 801*0e209d39SAndroid Build Coastguard Worker unum_parseDouble( const UNumberFormat* fmt, 802*0e209d39SAndroid Build Coastguard Worker const UChar* text, 803*0e209d39SAndroid Build Coastguard Worker int32_t textLength, 804*0e209d39SAndroid Build Coastguard Worker int32_t *parsePos /* 0 = start */, 805*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 806*0e209d39SAndroid Build Coastguard Worker 807*0e209d39SAndroid Build Coastguard Worker 808*0e209d39SAndroid Build Coastguard Worker /** 809*0e209d39SAndroid Build Coastguard Worker * Parse a number from a string into an unformatted numeric string using a UNumberFormat. 810*0e209d39SAndroid Build Coastguard Worker * The input string will be parsed according to the UNumberFormat's locale. 811*0e209d39SAndroid Build Coastguard Worker * The syntax of the output is a "numeric string" 812*0e209d39SAndroid Build Coastguard Worker * as defined in the Decimal Arithmetic Specification, available at 813*0e209d39SAndroid Build Coastguard Worker * http://speleotrove.com/decimal 814*0e209d39SAndroid Build Coastguard Worker * Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT 815*0e209d39SAndroid Build Coastguard Worker * and UNUM_DECIMAL_COMPACT_LONG. 816*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to use. 817*0e209d39SAndroid Build Coastguard Worker * @param text The text to parse. 818*0e209d39SAndroid Build Coastguard Worker * @param textLength The length of text, or -1 if null-terminated. 819*0e209d39SAndroid Build Coastguard Worker * @param parsePos If not NULL, on input a pointer to an integer specifying the offset at which 820*0e209d39SAndroid Build Coastguard Worker * to begin parsing. If not NULL, on output the offset at which parsing ended. 821*0e209d39SAndroid Build Coastguard Worker * @param outBuf A (char *) buffer to receive the parsed number as a string. The output string 822*0e209d39SAndroid Build Coastguard Worker * will be nul-terminated if there is sufficient space. 823*0e209d39SAndroid Build Coastguard Worker * @param outBufLength The size of the output buffer. May be zero, in which case 824*0e209d39SAndroid Build Coastguard Worker * the outBuf pointer may be NULL, and the function will return the 825*0e209d39SAndroid Build Coastguard Worker * size of the output string. 826*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 827*0e209d39SAndroid Build Coastguard Worker * @return the length of the output string, not including any terminating nul. 828*0e209d39SAndroid Build Coastguard Worker * @see unum_parse 829*0e209d39SAndroid Build Coastguard Worker * @see unum_parseInt64 830*0e209d39SAndroid Build Coastguard Worker * @see unum_format 831*0e209d39SAndroid Build Coastguard Worker * @see unum_formatInt64 832*0e209d39SAndroid Build Coastguard Worker * @see unum_formatDouble 833*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.4 834*0e209d39SAndroid Build Coastguard Worker */ 835*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 836*0e209d39SAndroid Build Coastguard Worker unum_parseDecimal(const UNumberFormat* fmt, 837*0e209d39SAndroid Build Coastguard Worker const UChar* text, 838*0e209d39SAndroid Build Coastguard Worker int32_t textLength, 839*0e209d39SAndroid Build Coastguard Worker int32_t *parsePos /* 0 = start */, 840*0e209d39SAndroid Build Coastguard Worker char *outBuf, 841*0e209d39SAndroid Build Coastguard Worker int32_t outBufLength, 842*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 843*0e209d39SAndroid Build Coastguard Worker 844*0e209d39SAndroid Build Coastguard Worker /** 845*0e209d39SAndroid Build Coastguard Worker * Parse a string into a double and a currency using a UNumberFormat. 846*0e209d39SAndroid Build Coastguard Worker * The string will be parsed according to the UNumberFormat's locale. 847*0e209d39SAndroid Build Coastguard Worker * @param fmt the formatter to use 848*0e209d39SAndroid Build Coastguard Worker * @param text the text to parse 849*0e209d39SAndroid Build Coastguard Worker * @param textLength the length of text, or -1 if null-terminated 850*0e209d39SAndroid Build Coastguard Worker * @param parsePos a pointer to an offset index into text at which to 851*0e209d39SAndroid Build Coastguard Worker * begin parsing. On output, *parsePos will point after the last 852*0e209d39SAndroid Build Coastguard Worker * parsed character. This parameter may be NULL, in which case parsing 853*0e209d39SAndroid Build Coastguard Worker * begins at offset 0. 854*0e209d39SAndroid Build Coastguard Worker * @param currency a pointer to the buffer to receive the parsed null- 855*0e209d39SAndroid Build Coastguard Worker * terminated currency. This buffer must have a capacity of at least 856*0e209d39SAndroid Build Coastguard Worker * 4 UChars. 857*0e209d39SAndroid Build Coastguard Worker * @param status a pointer to an input-output UErrorCode 858*0e209d39SAndroid Build Coastguard Worker * @return the parsed double 859*0e209d39SAndroid Build Coastguard Worker * @see unum_parseDouble 860*0e209d39SAndroid Build Coastguard Worker * @see unum_formatDoubleCurrency 861*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 862*0e209d39SAndroid Build Coastguard Worker */ 863*0e209d39SAndroid Build Coastguard Worker U_CAPI double U_EXPORT2 864*0e209d39SAndroid Build Coastguard Worker unum_parseDoubleCurrency(const UNumberFormat* fmt, 865*0e209d39SAndroid Build Coastguard Worker const UChar* text, 866*0e209d39SAndroid Build Coastguard Worker int32_t textLength, 867*0e209d39SAndroid Build Coastguard Worker int32_t* parsePos, /* 0 = start */ 868*0e209d39SAndroid Build Coastguard Worker UChar* currency, 869*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 870*0e209d39SAndroid Build Coastguard Worker 871*0e209d39SAndroid Build Coastguard Worker /** 872*0e209d39SAndroid Build Coastguard Worker * Parse a UChar string into a UFormattable. 873*0e209d39SAndroid Build Coastguard Worker * Example code: 874*0e209d39SAndroid Build Coastguard Worker * \snippet test/cintltst/cnumtst.c unum_parseToUFormattable 875*0e209d39SAndroid Build Coastguard Worker * Note: parsing is not supported for styles UNUM_DECIMAL_COMPACT_SHORT 876*0e209d39SAndroid Build Coastguard Worker * and UNUM_DECIMAL_COMPACT_LONG. 877*0e209d39SAndroid Build Coastguard Worker * @param fmt the formatter to use 878*0e209d39SAndroid Build Coastguard Worker * @param result the UFormattable to hold the result. If NULL, a new UFormattable will be allocated (which the caller must close with ufmt_close). 879*0e209d39SAndroid Build Coastguard Worker * @param text the text to parse 880*0e209d39SAndroid Build Coastguard Worker * @param textLength the length of text, or -1 if null-terminated 881*0e209d39SAndroid Build Coastguard Worker * @param parsePos a pointer to an offset index into text at which to 882*0e209d39SAndroid Build Coastguard Worker * begin parsing. On output, *parsePos will point after the last 883*0e209d39SAndroid Build Coastguard Worker * parsed character. This parameter may be NULL in which case parsing 884*0e209d39SAndroid Build Coastguard Worker * begins at offset 0. 885*0e209d39SAndroid Build Coastguard Worker * @param status a pointer to an input-output UErrorCode 886*0e209d39SAndroid Build Coastguard Worker * @return the UFormattable. Will be ==result unless NULL was passed in for result, in which case it will be the newly opened UFormattable. 887*0e209d39SAndroid Build Coastguard Worker * @see ufmt_getType 888*0e209d39SAndroid Build Coastguard Worker * @see ufmt_close 889*0e209d39SAndroid Build Coastguard Worker * @stable ICU 52 890*0e209d39SAndroid Build Coastguard Worker */ 891*0e209d39SAndroid Build Coastguard Worker U_CAPI UFormattable* U_EXPORT2 892*0e209d39SAndroid Build Coastguard Worker unum_parseToUFormattable(const UNumberFormat* fmt, 893*0e209d39SAndroid Build Coastguard Worker UFormattable *result, 894*0e209d39SAndroid Build Coastguard Worker const UChar* text, 895*0e209d39SAndroid Build Coastguard Worker int32_t textLength, 896*0e209d39SAndroid Build Coastguard Worker int32_t* parsePos, /* 0 = start */ 897*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 898*0e209d39SAndroid Build Coastguard Worker 899*0e209d39SAndroid Build Coastguard Worker /** 900*0e209d39SAndroid Build Coastguard Worker * Set the pattern used by a UNumberFormat. This can only be used 901*0e209d39SAndroid Build Coastguard Worker * on a DecimalFormat, other formats return U_UNSUPPORTED_ERROR 902*0e209d39SAndroid Build Coastguard Worker * in the status. 903*0e209d39SAndroid Build Coastguard Worker * @param format The formatter to set. 904*0e209d39SAndroid Build Coastguard Worker * @param localized true if the pattern is localized, false otherwise. 905*0e209d39SAndroid Build Coastguard Worker * @param pattern The new pattern 906*0e209d39SAndroid Build Coastguard Worker * @param patternLength The length of pattern, or -1 if null-terminated. 907*0e209d39SAndroid Build Coastguard Worker * @param parseError A pointer to UParseError to receive information 908*0e209d39SAndroid Build Coastguard Worker * about errors occurred during parsing, or NULL if no parse error 909*0e209d39SAndroid Build Coastguard Worker * information is desired. 910*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an input-output UErrorCode. 911*0e209d39SAndroid Build Coastguard Worker * @see unum_toPattern 912*0e209d39SAndroid Build Coastguard Worker * @see DecimalFormat 913*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 914*0e209d39SAndroid Build Coastguard Worker */ 915*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 916*0e209d39SAndroid Build Coastguard Worker unum_applyPattern( UNumberFormat *format, 917*0e209d39SAndroid Build Coastguard Worker UBool localized, 918*0e209d39SAndroid Build Coastguard Worker const UChar *pattern, 919*0e209d39SAndroid Build Coastguard Worker int32_t patternLength, 920*0e209d39SAndroid Build Coastguard Worker UParseError *parseError, 921*0e209d39SAndroid Build Coastguard Worker UErrorCode *status 922*0e209d39SAndroid Build Coastguard Worker ); 923*0e209d39SAndroid Build Coastguard Worker 924*0e209d39SAndroid Build Coastguard Worker /** 925*0e209d39SAndroid Build Coastguard Worker * Get a locale for which decimal formatting patterns are available. 926*0e209d39SAndroid Build Coastguard Worker * A UNumberFormat in a locale returned by this function will perform the correct 927*0e209d39SAndroid Build Coastguard Worker * formatting and parsing for the locale. The results of this call are not 928*0e209d39SAndroid Build Coastguard Worker * valid for rule-based number formats. 929*0e209d39SAndroid Build Coastguard Worker * @param localeIndex The index of the desired locale. 930*0e209d39SAndroid Build Coastguard Worker * @return A locale for which number formatting patterns are available, or 0 if none. 931*0e209d39SAndroid Build Coastguard Worker * @see unum_countAvailable 932*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 933*0e209d39SAndroid Build Coastguard Worker */ 934*0e209d39SAndroid Build Coastguard Worker U_CAPI const char* U_EXPORT2 935*0e209d39SAndroid Build Coastguard Worker unum_getAvailable(int32_t localeIndex); 936*0e209d39SAndroid Build Coastguard Worker 937*0e209d39SAndroid Build Coastguard Worker /** 938*0e209d39SAndroid Build Coastguard Worker * Determine how many locales have decimal formatting patterns available. The 939*0e209d39SAndroid Build Coastguard Worker * results of this call are not valid for rule-based number formats. 940*0e209d39SAndroid Build Coastguard Worker * This function is useful for determining the loop ending condition for 941*0e209d39SAndroid Build Coastguard Worker * calls to {@link #unum_getAvailable }. 942*0e209d39SAndroid Build Coastguard Worker * @return The number of locales for which decimal formatting patterns are available. 943*0e209d39SAndroid Build Coastguard Worker * @see unum_getAvailable 944*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 945*0e209d39SAndroid Build Coastguard Worker */ 946*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 947*0e209d39SAndroid Build Coastguard Worker unum_countAvailable(void); 948*0e209d39SAndroid Build Coastguard Worker 949*0e209d39SAndroid Build Coastguard Worker #if UCONFIG_HAVE_PARSEALLINPUT 950*0e209d39SAndroid Build Coastguard Worker /* The UNumberFormatAttributeValue type cannot be #ifndef U_HIDE_INTERNAL_API, needed for .h variable declaration */ 951*0e209d39SAndroid Build Coastguard Worker /** 952*0e209d39SAndroid Build Coastguard Worker * @internal 953*0e209d39SAndroid Build Coastguard Worker */ 954*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberFormatAttributeValue { 955*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 956*0e209d39SAndroid Build Coastguard Worker /** @internal */ 957*0e209d39SAndroid Build Coastguard Worker UNUM_NO = 0, 958*0e209d39SAndroid Build Coastguard Worker /** @internal */ 959*0e209d39SAndroid Build Coastguard Worker UNUM_YES = 1, 960*0e209d39SAndroid Build Coastguard Worker /** @internal */ 961*0e209d39SAndroid Build Coastguard Worker UNUM_MAYBE = 2 962*0e209d39SAndroid Build Coastguard Worker #else 963*0e209d39SAndroid Build Coastguard Worker /** @internal */ 964*0e209d39SAndroid Build Coastguard Worker UNUM_FORMAT_ATTRIBUTE_VALUE_HIDDEN 965*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 966*0e209d39SAndroid Build Coastguard Worker } UNumberFormatAttributeValue; 967*0e209d39SAndroid Build Coastguard Worker #endif 968*0e209d39SAndroid Build Coastguard Worker 969*0e209d39SAndroid Build Coastguard Worker /** The possible UNumberFormat numeric attributes @stable ICU 2.0 */ 970*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberFormatAttribute { 971*0e209d39SAndroid Build Coastguard Worker /** Parse integers only */ 972*0e209d39SAndroid Build Coastguard Worker UNUM_PARSE_INT_ONLY, 973*0e209d39SAndroid Build Coastguard Worker /** Use grouping separator */ 974*0e209d39SAndroid Build Coastguard Worker UNUM_GROUPING_USED, 975*0e209d39SAndroid Build Coastguard Worker /** Always show decimal point */ 976*0e209d39SAndroid Build Coastguard Worker UNUM_DECIMAL_ALWAYS_SHOWN, 977*0e209d39SAndroid Build Coastguard Worker /** Maximum integer digits */ 978*0e209d39SAndroid Build Coastguard Worker UNUM_MAX_INTEGER_DIGITS, 979*0e209d39SAndroid Build Coastguard Worker /** Minimum integer digits */ 980*0e209d39SAndroid Build Coastguard Worker UNUM_MIN_INTEGER_DIGITS, 981*0e209d39SAndroid Build Coastguard Worker /** Integer digits */ 982*0e209d39SAndroid Build Coastguard Worker UNUM_INTEGER_DIGITS, 983*0e209d39SAndroid Build Coastguard Worker /** Maximum fraction digits */ 984*0e209d39SAndroid Build Coastguard Worker UNUM_MAX_FRACTION_DIGITS, 985*0e209d39SAndroid Build Coastguard Worker /** Minimum fraction digits */ 986*0e209d39SAndroid Build Coastguard Worker UNUM_MIN_FRACTION_DIGITS, 987*0e209d39SAndroid Build Coastguard Worker /** Fraction digits */ 988*0e209d39SAndroid Build Coastguard Worker UNUM_FRACTION_DIGITS, 989*0e209d39SAndroid Build Coastguard Worker /** Multiplier */ 990*0e209d39SAndroid Build Coastguard Worker UNUM_MULTIPLIER, 991*0e209d39SAndroid Build Coastguard Worker /** Grouping size */ 992*0e209d39SAndroid Build Coastguard Worker UNUM_GROUPING_SIZE, 993*0e209d39SAndroid Build Coastguard Worker /** Rounding Mode */ 994*0e209d39SAndroid Build Coastguard Worker UNUM_ROUNDING_MODE, 995*0e209d39SAndroid Build Coastguard Worker /** Rounding increment */ 996*0e209d39SAndroid Build Coastguard Worker UNUM_ROUNDING_INCREMENT, 997*0e209d39SAndroid Build Coastguard Worker /** The width to which the output of <code>format()</code> is padded. */ 998*0e209d39SAndroid Build Coastguard Worker UNUM_FORMAT_WIDTH, 999*0e209d39SAndroid Build Coastguard Worker /** The position at which padding will take place. */ 1000*0e209d39SAndroid Build Coastguard Worker UNUM_PADDING_POSITION, 1001*0e209d39SAndroid Build Coastguard Worker /** Secondary grouping size */ 1002*0e209d39SAndroid Build Coastguard Worker UNUM_SECONDARY_GROUPING_SIZE, 1003*0e209d39SAndroid Build Coastguard Worker /** Use significant digits 1004*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 */ 1005*0e209d39SAndroid Build Coastguard Worker UNUM_SIGNIFICANT_DIGITS_USED, 1006*0e209d39SAndroid Build Coastguard Worker /** Minimum significant digits 1007*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 */ 1008*0e209d39SAndroid Build Coastguard Worker UNUM_MIN_SIGNIFICANT_DIGITS, 1009*0e209d39SAndroid Build Coastguard Worker /** Maximum significant digits 1010*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 */ 1011*0e209d39SAndroid Build Coastguard Worker UNUM_MAX_SIGNIFICANT_DIGITS, 1012*0e209d39SAndroid Build Coastguard Worker /** Lenient parse mode used by rule-based formats. 1013*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 1014*0e209d39SAndroid Build Coastguard Worker */ 1015*0e209d39SAndroid Build Coastguard Worker UNUM_LENIENT_PARSE, 1016*0e209d39SAndroid Build Coastguard Worker #if UCONFIG_HAVE_PARSEALLINPUT 1017*0e209d39SAndroid Build Coastguard Worker /** Consume all input. (may use fastpath). Set to UNUM_YES (require fastpath), UNUM_NO (skip fastpath), or UNUM_MAYBE (heuristic). 1018*0e209d39SAndroid Build Coastguard Worker * This is an internal ICU API. Do not use. 1019*0e209d39SAndroid Build Coastguard Worker * @internal 1020*0e209d39SAndroid Build Coastguard Worker */ 1021*0e209d39SAndroid Build Coastguard Worker UNUM_PARSE_ALL_INPUT = 20, 1022*0e209d39SAndroid Build Coastguard Worker #endif 1023*0e209d39SAndroid Build Coastguard Worker /** 1024*0e209d39SAndroid Build Coastguard Worker * Scale, which adjusts the position of the 1025*0e209d39SAndroid Build Coastguard Worker * decimal point when formatting. Amounts will be multiplied by 10 ^ (scale) 1026*0e209d39SAndroid Build Coastguard Worker * before they are formatted. The default value for the scale is 0 ( no adjustment ). 1027*0e209d39SAndroid Build Coastguard Worker * 1028*0e209d39SAndroid Build Coastguard Worker * <p>Example: setting the scale to 3, 123 formats as "123,000" 1029*0e209d39SAndroid Build Coastguard Worker * <p>Example: setting the scale to -4, 123 formats as "0.0123" 1030*0e209d39SAndroid Build Coastguard Worker * 1031*0e209d39SAndroid Build Coastguard Worker * This setting is analogous to getMultiplierScale() and setMultiplierScale() in decimfmt.h. 1032*0e209d39SAndroid Build Coastguard Worker * 1033*0e209d39SAndroid Build Coastguard Worker * @stable ICU 51 */ 1034*0e209d39SAndroid Build Coastguard Worker UNUM_SCALE = 21, 1035*0e209d39SAndroid Build Coastguard Worker 1036*0e209d39SAndroid Build Coastguard Worker /** 1037*0e209d39SAndroid Build Coastguard Worker * Minimum grouping digits; most commonly set to 2 to print "1000" instead of "1,000". 1038*0e209d39SAndroid Build Coastguard Worker * See DecimalFormat::getMinimumGroupingDigits(). 1039*0e209d39SAndroid Build Coastguard Worker * 1040*0e209d39SAndroid Build Coastguard Worker * For better control over grouping strategies, use UNumberFormatter. 1041*0e209d39SAndroid Build Coastguard Worker * 1042*0e209d39SAndroid Build Coastguard Worker * @stable ICU 64 1043*0e209d39SAndroid Build Coastguard Worker */ 1044*0e209d39SAndroid Build Coastguard Worker UNUM_MINIMUM_GROUPING_DIGITS = 22, 1045*0e209d39SAndroid Build Coastguard Worker 1046*0e209d39SAndroid Build Coastguard Worker /** 1047*0e209d39SAndroid Build Coastguard Worker * if this attribute is set to 0, it is set to UNUM_CURRENCY_STANDARD purpose, 1048*0e209d39SAndroid Build Coastguard Worker * otherwise it is UNUM_CASH_CURRENCY purpose 1049*0e209d39SAndroid Build Coastguard Worker * Default: 0 (UNUM_CURRENCY_STANDARD purpose) 1050*0e209d39SAndroid Build Coastguard Worker * @stable ICU 54 1051*0e209d39SAndroid Build Coastguard Worker */ 1052*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY_USAGE = 23, 1053*0e209d39SAndroid Build Coastguard Worker 1054*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 1055*0e209d39SAndroid Build Coastguard Worker /** One below the first bitfield-boolean item. 1056*0e209d39SAndroid Build Coastguard Worker * All items after this one are stored in boolean form. 1057*0e209d39SAndroid Build Coastguard Worker * @internal */ 1058*0e209d39SAndroid Build Coastguard Worker UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 0x0FFF, 1059*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 1060*0e209d39SAndroid Build Coastguard Worker 1061*0e209d39SAndroid Build Coastguard Worker /** If 1, specifies that if setting the "max integer digits" attribute would truncate a value, set an error status rather than silently truncating. 1062*0e209d39SAndroid Build Coastguard Worker * For example, formatting the value 1234 with 4 max int digits would succeed, but formatting 12345 would fail. There is no effect on parsing. 1063*0e209d39SAndroid Build Coastguard Worker * Default: 0 (not set) 1064*0e209d39SAndroid Build Coastguard Worker * @stable ICU 50 1065*0e209d39SAndroid Build Coastguard Worker */ 1066*0e209d39SAndroid Build Coastguard Worker UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 0x1000, 1067*0e209d39SAndroid Build Coastguard Worker /** 1068*0e209d39SAndroid Build Coastguard Worker * if this attribute is set to 1, specifies that, if the pattern doesn't contain an exponent, the exponent will not be parsed. If the pattern does contain an exponent, this attribute has no effect. 1069*0e209d39SAndroid Build Coastguard Worker * Has no effect on formatting. 1070*0e209d39SAndroid Build Coastguard Worker * Default: 0 (unset) 1071*0e209d39SAndroid Build Coastguard Worker * @stable ICU 50 1072*0e209d39SAndroid Build Coastguard Worker */ 1073*0e209d39SAndroid Build Coastguard Worker UNUM_PARSE_NO_EXPONENT = 0x1001, 1074*0e209d39SAndroid Build Coastguard Worker 1075*0e209d39SAndroid Build Coastguard Worker /** 1076*0e209d39SAndroid Build Coastguard Worker * if this attribute is set to 1, specifies that, if the pattern contains a 1077*0e209d39SAndroid Build Coastguard Worker * decimal mark the input is required to have one. If this attribute is set to 0, 1078*0e209d39SAndroid Build Coastguard Worker * specifies that input does not have to contain a decimal mark. 1079*0e209d39SAndroid Build Coastguard Worker * Has no effect on formatting. 1080*0e209d39SAndroid Build Coastguard Worker * Default: 0 (unset) 1081*0e209d39SAndroid Build Coastguard Worker * @stable ICU 54 1082*0e209d39SAndroid Build Coastguard Worker */ 1083*0e209d39SAndroid Build Coastguard Worker UNUM_PARSE_DECIMAL_MARK_REQUIRED = 0x1002, 1084*0e209d39SAndroid Build Coastguard Worker 1085*0e209d39SAndroid Build Coastguard Worker /** 1086*0e209d39SAndroid Build Coastguard Worker * Parsing: if set to 1, parsing is sensitive to case (lowercase/uppercase). 1087*0e209d39SAndroid Build Coastguard Worker * 1088*0e209d39SAndroid Build Coastguard Worker * @stable ICU 64 1089*0e209d39SAndroid Build Coastguard Worker */ 1090*0e209d39SAndroid Build Coastguard Worker UNUM_PARSE_CASE_SENSITIVE = 0x1003, 1091*0e209d39SAndroid Build Coastguard Worker 1092*0e209d39SAndroid Build Coastguard Worker /** 1093*0e209d39SAndroid Build Coastguard Worker * Formatting: if set to 1, whether to show the plus sign on non-negative numbers. 1094*0e209d39SAndroid Build Coastguard Worker * 1095*0e209d39SAndroid Build Coastguard Worker * For better control over sign display, use UNumberFormatter. 1096*0e209d39SAndroid Build Coastguard Worker * 1097*0e209d39SAndroid Build Coastguard Worker * @stable ICU 64 1098*0e209d39SAndroid Build Coastguard Worker */ 1099*0e209d39SAndroid Build Coastguard Worker UNUM_SIGN_ALWAYS_SHOWN = 0x1004, 1100*0e209d39SAndroid Build Coastguard Worker 1101*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 1102*0e209d39SAndroid Build Coastguard Worker /** Limit of boolean attributes. (value should 1103*0e209d39SAndroid Build Coastguard Worker * not depend on U_HIDE conditionals) 1104*0e209d39SAndroid Build Coastguard Worker * @internal */ 1105*0e209d39SAndroid Build Coastguard Worker UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 0x1005, 1106*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 1107*0e209d39SAndroid Build Coastguard Worker 1108*0e209d39SAndroid Build Coastguard Worker } UNumberFormatAttribute; 1109*0e209d39SAndroid Build Coastguard Worker 1110*0e209d39SAndroid Build Coastguard Worker /** 1111*0e209d39SAndroid Build Coastguard Worker * Returns true if the formatter supports the specified attribute and false if not. 1112*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to query. 1113*0e209d39SAndroid Build Coastguard Worker * @param attr The attribute to query. This can be any value of UNumberFormatterAttribute, 1114*0e209d39SAndroid Build Coastguard Worker * regardless of type. 1115*0e209d39SAndroid Build Coastguard Worker * @return True if the requested attribute is supported by the formatter; false if not. 1116*0e209d39SAndroid Build Coastguard Worker * @see unum_getAttribute 1117*0e209d39SAndroid Build Coastguard Worker * @see unum_setAttribute 1118*0e209d39SAndroid Build Coastguard Worker * @see unum_getDoubleAttribute 1119*0e209d39SAndroid Build Coastguard Worker * @see unum_setDoubleAttribute 1120*0e209d39SAndroid Build Coastguard Worker * @see unum_getTextAttribute 1121*0e209d39SAndroid Build Coastguard Worker * @see unum_setTextAttribute 1122*0e209d39SAndroid Build Coastguard Worker * @stable ICU 72 1123*0e209d39SAndroid Build Coastguard Worker */ 1124*0e209d39SAndroid Build Coastguard Worker U_CAPI bool U_EXPORT2 1125*0e209d39SAndroid Build Coastguard Worker unum_hasAttribute(const UNumberFormat* fmt, 1126*0e209d39SAndroid Build Coastguard Worker UNumberFormatAttribute attr); 1127*0e209d39SAndroid Build Coastguard Worker 1128*0e209d39SAndroid Build Coastguard Worker /** 1129*0e209d39SAndroid Build Coastguard Worker * Get a numeric attribute associated with a UNumberFormat. 1130*0e209d39SAndroid Build Coastguard Worker * An example of a numeric attribute is the number of integer digits a formatter will produce. 1131*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to query. 1132*0e209d39SAndroid Build Coastguard Worker * @param attr The attribute to query; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_USED, 1133*0e209d39SAndroid Build Coastguard Worker * UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_INTEGER_DIGITS, 1134*0e209d39SAndroid Build Coastguard Worker * UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM_MULTIPLIER, 1135*0e209d39SAndroid Build Coastguard Worker * UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITION, UNUM_SECONDARY_GROUPING_SIZE, 1136*0e209d39SAndroid Build Coastguard Worker * UNUM_SCALE, UNUM_MINIMUM_GROUPING_DIGITS. 1137*0e209d39SAndroid Build Coastguard Worker * @return The value of attr, or -1 if the formatter doesn't have the requested attribute. The caller should use unum_hasAttribute() to tell if the attribute 1138*0e209d39SAndroid Build Coastguard Worker * is available, rather than relaying on this function returning -1. 1139*0e209d39SAndroid Build Coastguard Worker * @see unum_hasAttribute 1140*0e209d39SAndroid Build Coastguard Worker * @see unum_setAttribute 1141*0e209d39SAndroid Build Coastguard Worker * @see unum_getDoubleAttribute 1142*0e209d39SAndroid Build Coastguard Worker * @see unum_setDoubleAttribute 1143*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1144*0e209d39SAndroid Build Coastguard Worker */ 1145*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1146*0e209d39SAndroid Build Coastguard Worker unum_getAttribute(const UNumberFormat* fmt, 1147*0e209d39SAndroid Build Coastguard Worker UNumberFormatAttribute attr); 1148*0e209d39SAndroid Build Coastguard Worker 1149*0e209d39SAndroid Build Coastguard Worker /** 1150*0e209d39SAndroid Build Coastguard Worker * Set a numeric attribute associated with a UNumberFormat. 1151*0e209d39SAndroid Build Coastguard Worker * An example of a numeric attribute is the number of integer digits a formatter will produce. If the 1152*0e209d39SAndroid Build Coastguard Worker * formatter does not understand the attribute, the call is ignored. Rule-based formatters only understand 1153*0e209d39SAndroid Build Coastguard Worker * the lenient-parse attribute. The caller can use unum_hasAttribute() to find out if the formatter supports the attribute. 1154*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to set. 1155*0e209d39SAndroid Build Coastguard Worker * @param attr The attribute to set; one of UNUM_PARSE_INT_ONLY, UNUM_GROUPING_USED, 1156*0e209d39SAndroid Build Coastguard Worker * UNUM_DECIMAL_ALWAYS_SHOWN, UNUM_MAX_INTEGER_DIGITS, UNUM_MIN_INTEGER_DIGITS, UNUM_INTEGER_DIGITS, 1157*0e209d39SAndroid Build Coastguard Worker * UNUM_MAX_FRACTION_DIGITS, UNUM_MIN_FRACTION_DIGITS, UNUM_FRACTION_DIGITS, UNUM_MULTIPLIER, 1158*0e209d39SAndroid Build Coastguard Worker * UNUM_GROUPING_SIZE, UNUM_ROUNDING_MODE, UNUM_FORMAT_WIDTH, UNUM_PADDING_POSITION, UNUM_SECONDARY_GROUPING_SIZE, 1159*0e209d39SAndroid Build Coastguard Worker * UNUM_LENIENT_PARSE, UNUM_SCALE, UNUM_MINIMUM_GROUPING_DIGITS. 1160*0e209d39SAndroid Build Coastguard Worker * @param newValue The new value of attr. 1161*0e209d39SAndroid Build Coastguard Worker * @see unum_hasAttribute 1162*0e209d39SAndroid Build Coastguard Worker * @see unum_getAttribute 1163*0e209d39SAndroid Build Coastguard Worker * @see unum_getDoubleAttribute 1164*0e209d39SAndroid Build Coastguard Worker * @see unum_setDoubleAttribute 1165*0e209d39SAndroid Build Coastguard Worker * @see unum_getTextAttribute 1166*0e209d39SAndroid Build Coastguard Worker * @see unum_setTextAttribute 1167*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1168*0e209d39SAndroid Build Coastguard Worker */ 1169*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1170*0e209d39SAndroid Build Coastguard Worker unum_setAttribute( UNumberFormat* fmt, 1171*0e209d39SAndroid Build Coastguard Worker UNumberFormatAttribute attr, 1172*0e209d39SAndroid Build Coastguard Worker int32_t newValue); 1173*0e209d39SAndroid Build Coastguard Worker 1174*0e209d39SAndroid Build Coastguard Worker 1175*0e209d39SAndroid Build Coastguard Worker /** 1176*0e209d39SAndroid Build Coastguard Worker * Get a numeric attribute associated with a UNumberFormat. 1177*0e209d39SAndroid Build Coastguard Worker * An example of a numeric attribute is the number of integer digits a formatter will produce. 1178*0e209d39SAndroid Build Coastguard Worker * If the formatter does not understand the attribute, -1 is returned. The caller should use unum_hasAttribute() 1179*0e209d39SAndroid Build Coastguard Worker * to determine if the attribute is supported, rather than relying on this function returning -1. 1180*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to query. 1181*0e209d39SAndroid Build Coastguard Worker * @param attr The attribute to query; e.g. UNUM_ROUNDING_INCREMENT. 1182*0e209d39SAndroid Build Coastguard Worker * @return The value of attr, or -1 if the formatter doesn't understand the attribute. 1183*0e209d39SAndroid Build Coastguard Worker * @see unum_hasAttribute 1184*0e209d39SAndroid Build Coastguard Worker * @see unum_getAttribute 1185*0e209d39SAndroid Build Coastguard Worker * @see unum_setAttribute 1186*0e209d39SAndroid Build Coastguard Worker * @see unum_setDoubleAttribute 1187*0e209d39SAndroid Build Coastguard Worker * @see unum_getTextAttribute 1188*0e209d39SAndroid Build Coastguard Worker * @see unum_setTextAttribute 1189*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1190*0e209d39SAndroid Build Coastguard Worker */ 1191*0e209d39SAndroid Build Coastguard Worker U_CAPI double U_EXPORT2 1192*0e209d39SAndroid Build Coastguard Worker unum_getDoubleAttribute(const UNumberFormat* fmt, 1193*0e209d39SAndroid Build Coastguard Worker UNumberFormatAttribute attr); 1194*0e209d39SAndroid Build Coastguard Worker 1195*0e209d39SAndroid Build Coastguard Worker /** 1196*0e209d39SAndroid Build Coastguard Worker * Set a numeric attribute associated with a UNumberFormat. 1197*0e209d39SAndroid Build Coastguard Worker * An example of a numeric attribute is the number of integer digits a formatter will produce. 1198*0e209d39SAndroid Build Coastguard Worker * If the formatter does not understand the attribute, this call is ignored. The caller can use 1199*0e209d39SAndroid Build Coastguard Worker * unum_hasAttribute() to tell in advance whether the formatter understands the attribute. 1200*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to set. 1201*0e209d39SAndroid Build Coastguard Worker * @param attr The attribute to set; e.g. UNUM_ROUNDING_INCREMENT. 1202*0e209d39SAndroid Build Coastguard Worker * @param newValue The new value of attr. 1203*0e209d39SAndroid Build Coastguard Worker * @see unum_hasAttribute 1204*0e209d39SAndroid Build Coastguard Worker * @see unum_getAttribute 1205*0e209d39SAndroid Build Coastguard Worker * @see unum_setAttribute 1206*0e209d39SAndroid Build Coastguard Worker * @see unum_getDoubleAttribute 1207*0e209d39SAndroid Build Coastguard Worker * @see unum_getTextAttribute 1208*0e209d39SAndroid Build Coastguard Worker * @see unum_setTextAttribute 1209*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1210*0e209d39SAndroid Build Coastguard Worker */ 1211*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1212*0e209d39SAndroid Build Coastguard Worker unum_setDoubleAttribute( UNumberFormat* fmt, 1213*0e209d39SAndroid Build Coastguard Worker UNumberFormatAttribute attr, 1214*0e209d39SAndroid Build Coastguard Worker double newValue); 1215*0e209d39SAndroid Build Coastguard Worker 1216*0e209d39SAndroid Build Coastguard Worker /** The possible UNumberFormat text attributes @stable ICU 2.0*/ 1217*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberFormatTextAttribute { 1218*0e209d39SAndroid Build Coastguard Worker /** Positive prefix */ 1219*0e209d39SAndroid Build Coastguard Worker UNUM_POSITIVE_PREFIX, 1220*0e209d39SAndroid Build Coastguard Worker /** Positive suffix */ 1221*0e209d39SAndroid Build Coastguard Worker UNUM_POSITIVE_SUFFIX, 1222*0e209d39SAndroid Build Coastguard Worker /** Negative prefix */ 1223*0e209d39SAndroid Build Coastguard Worker UNUM_NEGATIVE_PREFIX, 1224*0e209d39SAndroid Build Coastguard Worker /** Negative suffix */ 1225*0e209d39SAndroid Build Coastguard Worker UNUM_NEGATIVE_SUFFIX, 1226*0e209d39SAndroid Build Coastguard Worker /** The character used to pad to the format width. */ 1227*0e209d39SAndroid Build Coastguard Worker UNUM_PADDING_CHARACTER, 1228*0e209d39SAndroid Build Coastguard Worker /** The ISO currency code */ 1229*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY_CODE, 1230*0e209d39SAndroid Build Coastguard Worker /** 1231*0e209d39SAndroid Build Coastguard Worker * The default rule set, such as "%spellout-numbering-year:", "%spellout-cardinal:", 1232*0e209d39SAndroid Build Coastguard Worker * "%spellout-ordinal-masculine-plural:", "%spellout-ordinal-feminine:", or 1233*0e209d39SAndroid Build Coastguard Worker * "%spellout-ordinal-neuter:". The available public rulesets can be listed using 1234*0e209d39SAndroid Build Coastguard Worker * unum_getTextAttribute with UNUM_PUBLIC_RULESETS. This is only available with 1235*0e209d39SAndroid Build Coastguard Worker * rule-based formatters. 1236*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 1237*0e209d39SAndroid Build Coastguard Worker */ 1238*0e209d39SAndroid Build Coastguard Worker UNUM_DEFAULT_RULESET, 1239*0e209d39SAndroid Build Coastguard Worker /** 1240*0e209d39SAndroid Build Coastguard Worker * The public rule sets. This is only available with rule-based formatters. 1241*0e209d39SAndroid Build Coastguard Worker * This is a read-only attribute. The public rulesets are returned as a 1242*0e209d39SAndroid Build Coastguard Worker * single string, with each ruleset name delimited by ';' (semicolon). See the 1243*0e209d39SAndroid Build Coastguard Worker * CLDR LDML spec for more information about RBNF rulesets: 1244*0e209d39SAndroid Build Coastguard Worker * http://www.unicode.org/reports/tr35/tr35-numbers.html#Rule-Based_Number_Formatting 1245*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 1246*0e209d39SAndroid Build Coastguard Worker */ 1247*0e209d39SAndroid Build Coastguard Worker UNUM_PUBLIC_RULESETS 1248*0e209d39SAndroid Build Coastguard Worker } UNumberFormatTextAttribute; 1249*0e209d39SAndroid Build Coastguard Worker 1250*0e209d39SAndroid Build Coastguard Worker /** 1251*0e209d39SAndroid Build Coastguard Worker * Get a text attribute associated with a UNumberFormat. 1252*0e209d39SAndroid Build Coastguard Worker * An example of a text attribute is the suffix for positive numbers. If the formatter 1253*0e209d39SAndroid Build Coastguard Worker * does not understand the attribute, U_UNSUPPORTED_ERROR is returned as the status. 1254*0e209d39SAndroid Build Coastguard Worker * Rule-based formatters only understand UNUM_DEFAULT_RULESET and UNUM_PUBLIC_RULESETS. 1255*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to query. 1256*0e209d39SAndroid Build Coastguard Worker * @param tag The attribute to query; one of UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX, 1257*0e209d39SAndroid Build Coastguard Worker * UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER, UNUM_CURRENCY_CODE, 1258*0e209d39SAndroid Build Coastguard Worker * UNUM_DEFAULT_RULESET, or UNUM_PUBLIC_RULESETS. 1259*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the attribute. 1260*0e209d39SAndroid Build Coastguard Worker * @param resultLength The maximum size of result. 1261*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 1262*0e209d39SAndroid Build Coastguard Worker * @return The total buffer size needed; if greater than resultLength, the output was truncated. 1263*0e209d39SAndroid Build Coastguard Worker * @see unum_setTextAttribute 1264*0e209d39SAndroid Build Coastguard Worker * @see unum_getAttribute 1265*0e209d39SAndroid Build Coastguard Worker * @see unum_setAttribute 1266*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1267*0e209d39SAndroid Build Coastguard Worker */ 1268*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1269*0e209d39SAndroid Build Coastguard Worker unum_getTextAttribute( const UNumberFormat* fmt, 1270*0e209d39SAndroid Build Coastguard Worker UNumberFormatTextAttribute tag, 1271*0e209d39SAndroid Build Coastguard Worker UChar* result, 1272*0e209d39SAndroid Build Coastguard Worker int32_t resultLength, 1273*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 1274*0e209d39SAndroid Build Coastguard Worker 1275*0e209d39SAndroid Build Coastguard Worker /** 1276*0e209d39SAndroid Build Coastguard Worker * Set a text attribute associated with a UNumberFormat. 1277*0e209d39SAndroid Build Coastguard Worker * An example of a text attribute is the suffix for positive numbers. Rule-based formatters 1278*0e209d39SAndroid Build Coastguard Worker * only understand UNUM_DEFAULT_RULESET. 1279*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to set. 1280*0e209d39SAndroid Build Coastguard Worker * @param tag The attribute to set; one of UNUM_POSITIVE_PREFIX, UNUM_POSITIVE_SUFFIX, 1281*0e209d39SAndroid Build Coastguard Worker * UNUM_NEGATIVE_PREFIX, UNUM_NEGATIVE_SUFFIX, UNUM_PADDING_CHARACTER, UNUM_CURRENCY_CODE, 1282*0e209d39SAndroid Build Coastguard Worker * or UNUM_DEFAULT_RULESET. 1283*0e209d39SAndroid Build Coastguard Worker * @param newValue The new value of attr. 1284*0e209d39SAndroid Build Coastguard Worker * @param newValueLength The length of newValue, or -1 if null-terminated. 1285*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 1286*0e209d39SAndroid Build Coastguard Worker * @see unum_getTextAttribute 1287*0e209d39SAndroid Build Coastguard Worker * @see unum_getAttribute 1288*0e209d39SAndroid Build Coastguard Worker * @see unum_setAttribute 1289*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1290*0e209d39SAndroid Build Coastguard Worker */ 1291*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1292*0e209d39SAndroid Build Coastguard Worker unum_setTextAttribute( UNumberFormat* fmt, 1293*0e209d39SAndroid Build Coastguard Worker UNumberFormatTextAttribute tag, 1294*0e209d39SAndroid Build Coastguard Worker const UChar* newValue, 1295*0e209d39SAndroid Build Coastguard Worker int32_t newValueLength, 1296*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1297*0e209d39SAndroid Build Coastguard Worker 1298*0e209d39SAndroid Build Coastguard Worker /** 1299*0e209d39SAndroid Build Coastguard Worker * Extract the pattern from a UNumberFormat. The pattern will follow 1300*0e209d39SAndroid Build Coastguard Worker * the DecimalFormat pattern syntax. 1301*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to query. 1302*0e209d39SAndroid Build Coastguard Worker * @param isPatternLocalized true if the pattern should be localized, 1303*0e209d39SAndroid Build Coastguard Worker * false otherwise. This is ignored if the formatter is a rule-based 1304*0e209d39SAndroid Build Coastguard Worker * formatter. 1305*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the pattern. 1306*0e209d39SAndroid Build Coastguard Worker * @param resultLength The maximum size of result. 1307*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an input-output UErrorCode. 1308*0e209d39SAndroid Build Coastguard Worker * @return The total buffer size needed; if greater than resultLength, 1309*0e209d39SAndroid Build Coastguard Worker * the output was truncated. 1310*0e209d39SAndroid Build Coastguard Worker * @see unum_applyPattern 1311*0e209d39SAndroid Build Coastguard Worker * @see DecimalFormat 1312*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1313*0e209d39SAndroid Build Coastguard Worker */ 1314*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1315*0e209d39SAndroid Build Coastguard Worker unum_toPattern( const UNumberFormat* fmt, 1316*0e209d39SAndroid Build Coastguard Worker UBool isPatternLocalized, 1317*0e209d39SAndroid Build Coastguard Worker UChar* result, 1318*0e209d39SAndroid Build Coastguard Worker int32_t resultLength, 1319*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 1320*0e209d39SAndroid Build Coastguard Worker 1321*0e209d39SAndroid Build Coastguard Worker 1322*0e209d39SAndroid Build Coastguard Worker /** 1323*0e209d39SAndroid Build Coastguard Worker * Constants for specifying a number format symbol. 1324*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1325*0e209d39SAndroid Build Coastguard Worker */ 1326*0e209d39SAndroid Build Coastguard Worker typedef enum UNumberFormatSymbol { 1327*0e209d39SAndroid Build Coastguard Worker /** The decimal separator */ 1328*0e209d39SAndroid Build Coastguard Worker UNUM_DECIMAL_SEPARATOR_SYMBOL = 0, 1329*0e209d39SAndroid Build Coastguard Worker /** The grouping separator */ 1330*0e209d39SAndroid Build Coastguard Worker UNUM_GROUPING_SEPARATOR_SYMBOL = 1, 1331*0e209d39SAndroid Build Coastguard Worker /** The pattern separator */ 1332*0e209d39SAndroid Build Coastguard Worker UNUM_PATTERN_SEPARATOR_SYMBOL = 2, 1333*0e209d39SAndroid Build Coastguard Worker /** The percent sign */ 1334*0e209d39SAndroid Build Coastguard Worker UNUM_PERCENT_SYMBOL = 3, 1335*0e209d39SAndroid Build Coastguard Worker /** Zero*/ 1336*0e209d39SAndroid Build Coastguard Worker UNUM_ZERO_DIGIT_SYMBOL = 4, 1337*0e209d39SAndroid Build Coastguard Worker /** Character representing a digit in the pattern */ 1338*0e209d39SAndroid Build Coastguard Worker UNUM_DIGIT_SYMBOL = 5, 1339*0e209d39SAndroid Build Coastguard Worker /** The minus sign */ 1340*0e209d39SAndroid Build Coastguard Worker UNUM_MINUS_SIGN_SYMBOL = 6, 1341*0e209d39SAndroid Build Coastguard Worker /** The plus sign */ 1342*0e209d39SAndroid Build Coastguard Worker UNUM_PLUS_SIGN_SYMBOL = 7, 1343*0e209d39SAndroid Build Coastguard Worker /** The currency symbol */ 1344*0e209d39SAndroid Build Coastguard Worker UNUM_CURRENCY_SYMBOL = 8, 1345*0e209d39SAndroid Build Coastguard Worker /** The international currency symbol */ 1346*0e209d39SAndroid Build Coastguard Worker UNUM_INTL_CURRENCY_SYMBOL = 9, 1347*0e209d39SAndroid Build Coastguard Worker /** The monetary separator */ 1348*0e209d39SAndroid Build Coastguard Worker UNUM_MONETARY_SEPARATOR_SYMBOL = 10, 1349*0e209d39SAndroid Build Coastguard Worker /** The exponential symbol */ 1350*0e209d39SAndroid Build Coastguard Worker UNUM_EXPONENTIAL_SYMBOL = 11, 1351*0e209d39SAndroid Build Coastguard Worker /** Per mill symbol */ 1352*0e209d39SAndroid Build Coastguard Worker UNUM_PERMILL_SYMBOL = 12, 1353*0e209d39SAndroid Build Coastguard Worker /** Escape padding character */ 1354*0e209d39SAndroid Build Coastguard Worker UNUM_PAD_ESCAPE_SYMBOL = 13, 1355*0e209d39SAndroid Build Coastguard Worker /** Infinity symbol */ 1356*0e209d39SAndroid Build Coastguard Worker UNUM_INFINITY_SYMBOL = 14, 1357*0e209d39SAndroid Build Coastguard Worker /** Nan symbol */ 1358*0e209d39SAndroid Build Coastguard Worker UNUM_NAN_SYMBOL = 15, 1359*0e209d39SAndroid Build Coastguard Worker /** Significant digit symbol 1360*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 */ 1361*0e209d39SAndroid Build Coastguard Worker UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16, 1362*0e209d39SAndroid Build Coastguard Worker /** The monetary grouping separator 1363*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.6 1364*0e209d39SAndroid Build Coastguard Worker */ 1365*0e209d39SAndroid Build Coastguard Worker UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17, 1366*0e209d39SAndroid Build Coastguard Worker /** One 1367*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1368*0e209d39SAndroid Build Coastguard Worker */ 1369*0e209d39SAndroid Build Coastguard Worker UNUM_ONE_DIGIT_SYMBOL = 18, 1370*0e209d39SAndroid Build Coastguard Worker /** Two 1371*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1372*0e209d39SAndroid Build Coastguard Worker */ 1373*0e209d39SAndroid Build Coastguard Worker UNUM_TWO_DIGIT_SYMBOL = 19, 1374*0e209d39SAndroid Build Coastguard Worker /** Three 1375*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1376*0e209d39SAndroid Build Coastguard Worker */ 1377*0e209d39SAndroid Build Coastguard Worker UNUM_THREE_DIGIT_SYMBOL = 20, 1378*0e209d39SAndroid Build Coastguard Worker /** Four 1379*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1380*0e209d39SAndroid Build Coastguard Worker */ 1381*0e209d39SAndroid Build Coastguard Worker UNUM_FOUR_DIGIT_SYMBOL = 21, 1382*0e209d39SAndroid Build Coastguard Worker /** Five 1383*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1384*0e209d39SAndroid Build Coastguard Worker */ 1385*0e209d39SAndroid Build Coastguard Worker UNUM_FIVE_DIGIT_SYMBOL = 22, 1386*0e209d39SAndroid Build Coastguard Worker /** Six 1387*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1388*0e209d39SAndroid Build Coastguard Worker */ 1389*0e209d39SAndroid Build Coastguard Worker UNUM_SIX_DIGIT_SYMBOL = 23, 1390*0e209d39SAndroid Build Coastguard Worker /** Seven 1391*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1392*0e209d39SAndroid Build Coastguard Worker */ 1393*0e209d39SAndroid Build Coastguard Worker UNUM_SEVEN_DIGIT_SYMBOL = 24, 1394*0e209d39SAndroid Build Coastguard Worker /** Eight 1395*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1396*0e209d39SAndroid Build Coastguard Worker */ 1397*0e209d39SAndroid Build Coastguard Worker UNUM_EIGHT_DIGIT_SYMBOL = 25, 1398*0e209d39SAndroid Build Coastguard Worker /** Nine 1399*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 1400*0e209d39SAndroid Build Coastguard Worker */ 1401*0e209d39SAndroid Build Coastguard Worker UNUM_NINE_DIGIT_SYMBOL = 26, 1402*0e209d39SAndroid Build Coastguard Worker 1403*0e209d39SAndroid Build Coastguard Worker /** Multiplication sign 1404*0e209d39SAndroid Build Coastguard Worker * @stable ICU 54 1405*0e209d39SAndroid Build Coastguard Worker */ 1406*0e209d39SAndroid Build Coastguard Worker UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27, 1407*0e209d39SAndroid Build Coastguard Worker 1408*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 1409*0e209d39SAndroid Build Coastguard Worker /** Approximately sign. 1410*0e209d39SAndroid Build Coastguard Worker * @internal 1411*0e209d39SAndroid Build Coastguard Worker */ 1412*0e209d39SAndroid Build Coastguard Worker UNUM_APPROXIMATELY_SIGN_SYMBOL = 28, 1413*0e209d39SAndroid Build Coastguard Worker #endif 1414*0e209d39SAndroid Build Coastguard Worker 1415*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 1416*0e209d39SAndroid Build Coastguard Worker /** 1417*0e209d39SAndroid Build Coastguard Worker * One more than the highest normal UNumberFormatSymbol value. 1418*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. 1419*0e209d39SAndroid Build Coastguard Worker */ 1420*0e209d39SAndroid Build Coastguard Worker UNUM_FORMAT_SYMBOL_COUNT = 29 1421*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 1422*0e209d39SAndroid Build Coastguard Worker } UNumberFormatSymbol; 1423*0e209d39SAndroid Build Coastguard Worker 1424*0e209d39SAndroid Build Coastguard Worker /** 1425*0e209d39SAndroid Build Coastguard Worker * Get a symbol associated with a UNumberFormat. 1426*0e209d39SAndroid Build Coastguard Worker * A UNumberFormat uses symbols to represent the special locale-dependent 1427*0e209d39SAndroid Build Coastguard Worker * characters in a number, for example the percent sign. This API is not 1428*0e209d39SAndroid Build Coastguard Worker * supported for rule-based formatters. 1429*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to query. 1430*0e209d39SAndroid Build Coastguard Worker * @param symbol The UNumberFormatSymbol constant for the symbol to get 1431*0e209d39SAndroid Build Coastguard Worker * @param buffer The string buffer that will receive the symbol string; 1432*0e209d39SAndroid Build Coastguard Worker * if it is NULL, then only the length of the symbol is returned 1433*0e209d39SAndroid Build Coastguard Worker * @param size The size of the string buffer 1434*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 1435*0e209d39SAndroid Build Coastguard Worker * @return The length of the symbol; the buffer is not modified if 1436*0e209d39SAndroid Build Coastguard Worker * <code>length>=size</code> 1437*0e209d39SAndroid Build Coastguard Worker * @see unum_setSymbol 1438*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1439*0e209d39SAndroid Build Coastguard Worker */ 1440*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1441*0e209d39SAndroid Build Coastguard Worker unum_getSymbol(const UNumberFormat *fmt, 1442*0e209d39SAndroid Build Coastguard Worker UNumberFormatSymbol symbol, 1443*0e209d39SAndroid Build Coastguard Worker UChar *buffer, 1444*0e209d39SAndroid Build Coastguard Worker int32_t size, 1445*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1446*0e209d39SAndroid Build Coastguard Worker 1447*0e209d39SAndroid Build Coastguard Worker /** 1448*0e209d39SAndroid Build Coastguard Worker * Set a symbol associated with a UNumberFormat. 1449*0e209d39SAndroid Build Coastguard Worker * A UNumberFormat uses symbols to represent the special locale-dependent 1450*0e209d39SAndroid Build Coastguard Worker * characters in a number, for example the percent sign. This API is not 1451*0e209d39SAndroid Build Coastguard Worker * supported for rule-based formatters. 1452*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to set. 1453*0e209d39SAndroid Build Coastguard Worker * @param symbol The UNumberFormatSymbol constant for the symbol to set 1454*0e209d39SAndroid Build Coastguard Worker * @param value The string to set the symbol to 1455*0e209d39SAndroid Build Coastguard Worker * @param length The length of the string, or -1 for a zero-terminated string 1456*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors. 1457*0e209d39SAndroid Build Coastguard Worker * @see unum_getSymbol 1458*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1459*0e209d39SAndroid Build Coastguard Worker */ 1460*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1461*0e209d39SAndroid Build Coastguard Worker unum_setSymbol(UNumberFormat *fmt, 1462*0e209d39SAndroid Build Coastguard Worker UNumberFormatSymbol symbol, 1463*0e209d39SAndroid Build Coastguard Worker const UChar *value, 1464*0e209d39SAndroid Build Coastguard Worker int32_t length, 1465*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1466*0e209d39SAndroid Build Coastguard Worker 1467*0e209d39SAndroid Build Coastguard Worker 1468*0e209d39SAndroid Build Coastguard Worker /** 1469*0e209d39SAndroid Build Coastguard Worker * Get the locale for this number format object. 1470*0e209d39SAndroid Build Coastguard Worker * You can choose between valid and actual locale. 1471*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to get the locale from 1472*0e209d39SAndroid Build Coastguard Worker * @param type type of the locale we're looking for (valid or actual) 1473*0e209d39SAndroid Build Coastguard Worker * @param status error code for the operation 1474*0e209d39SAndroid Build Coastguard Worker * @return the locale name 1475*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.8 1476*0e209d39SAndroid Build Coastguard Worker */ 1477*0e209d39SAndroid Build Coastguard Worker U_CAPI const char* U_EXPORT2 1478*0e209d39SAndroid Build Coastguard Worker unum_getLocaleByType(const UNumberFormat *fmt, 1479*0e209d39SAndroid Build Coastguard Worker ULocDataLocaleType type, 1480*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 1481*0e209d39SAndroid Build Coastguard Worker 1482*0e209d39SAndroid Build Coastguard Worker /** 1483*0e209d39SAndroid Build Coastguard Worker * Set a particular UDisplayContext value in the formatter, such as 1484*0e209d39SAndroid Build Coastguard Worker * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. 1485*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter for which to set a UDisplayContext value. 1486*0e209d39SAndroid Build Coastguard Worker * @param value The UDisplayContext value to set. 1487*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 1488*0e209d39SAndroid Build Coastguard Worker * @stable ICU 53 1489*0e209d39SAndroid Build Coastguard Worker */ 1490*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1491*0e209d39SAndroid Build Coastguard Worker unum_setContext(UNumberFormat* fmt, UDisplayContext value, UErrorCode* status); 1492*0e209d39SAndroid Build Coastguard Worker 1493*0e209d39SAndroid Build Coastguard Worker /** 1494*0e209d39SAndroid Build Coastguard Worker * Get the formatter's UDisplayContext value for the specified UDisplayContextType, 1495*0e209d39SAndroid Build Coastguard Worker * such as UDISPCTX_TYPE_CAPITALIZATION. 1496*0e209d39SAndroid Build Coastguard Worker * @param fmt The formatter to query. 1497*0e209d39SAndroid Build Coastguard Worker * @param type The UDisplayContextType whose value to return 1498*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to an UErrorCode to receive any errors 1499*0e209d39SAndroid Build Coastguard Worker * @return The UDisplayContextValue for the specified type. 1500*0e209d39SAndroid Build Coastguard Worker * @stable ICU 53 1501*0e209d39SAndroid Build Coastguard Worker */ 1502*0e209d39SAndroid Build Coastguard Worker U_CAPI UDisplayContext U_EXPORT2 1503*0e209d39SAndroid Build Coastguard Worker unum_getContext(const UNumberFormat *fmt, UDisplayContextType type, UErrorCode* status); 1504*0e209d39SAndroid Build Coastguard Worker 1505*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_FORMATTING */ 1506*0e209d39SAndroid Build Coastguard Worker 1507*0e209d39SAndroid Build Coastguard Worker #endif 1508