Home | History | Annotate | Download | only in unicode
      1 //  2018 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html
      3 
      4 #include "unicode/utypes.h"
      5 
      6 #if !UCONFIG_NO_FORMATTING
      7 #ifndef __UNUMBERFORMATTER_H__
      8 #define __UNUMBERFORMATTER_H__
      9 
     10 #include "unicode/ufieldpositer.h"
     11 #include "unicode/umisc.h"
     12 
     13 
     14 /**
     15  * \file
     16  * \brief C-compatible API for localized number formatting; not recommended for C++.
     17  *
     18  * This is the C-compatible version of the NumberFormatter API introduced in ICU 60. C++ users should
     19  * include unicode/numberformatter.h and use the proper C++ APIs.
     20  *
     21  * The C API accepts a number skeleton string for specifying the settings for formatting, which covers a
     22  * very large subset of all possible number formatting features. For more information on number skeleton
     23  * strings, see unicode/numberformatter.h.
     24  *
     25  * When using UNumberFormatter, which is treated as immutable, the results are exported to a mutable
     26  * UFormattedNumber object, which you subsequently use for populating your string buffer or iterating over
     27  * the fields.
     28  *
     29  * Example code:
     30  * <pre>
     31  * // Setup:
     32  * UErrorCode ec = U_ZERO_ERROR;
     33  * UNumberFormatter* uformatter = unumf_openForSkeletonAndLocale(u"precision-integer", -1, "en", &ec);
     34  * UFormattedNumber* uresult = unumf_openResult(&ec);
     35  * if (U_FAILURE(ec)) { return; }
     36  *
     37  * // Format a double:
     38  * unumf_formatDouble(uformatter, 5142.3, uresult, &ec);
     39  * if (U_FAILURE(ec)) { return; }
     40  *
     41  * // Export the string to a malloc'd buffer:
     42  * int32_t len = unumf_resultToString(uresult, NULL, 0, &ec);
     43  * // at this point, ec == U_BUFFER_OVERFLOW_ERROR
     44  * ec = U_ZERO_ERROR;
     45  * UChar* buffer = (UChar*) malloc((len+1)*sizeof(UChar));
     46  * unumf_resultToString(uresult, buffer, len+1, &ec);
     47  * if (U_FAILURE(ec)) { return; }
     48  * // buffer should equal "5,142"
     49  *
     50  * // Cleanup:
     51  * unumf_close(uformatter);
     52  * unumf_closeResult(uresult);
     53  * free(buffer);
     54  * </pre>
     55  *
     56  * If you are a C++ user linking against the C libraries, you can use the LocalPointer versions of these
     57  * APIs. The following example uses LocalPointer with the decimal number and field position APIs:
     58  *
     59  * <pre>
     60  * // Setup:
     61  * LocalUNumberFormatterPointer uformatter(unumf_openForSkeletonAndLocale(u"percent", -1, "en", &ec));
     62  * LocalUFormattedNumberPointer uresult(unumf_openResult(&ec));
     63  * if (U_FAILURE(ec)) { return; }
     64  *
     65  * // Format a decimal number:
     66  * unumf_formatDecimal(uformatter.getAlias(), "9.87E-3", -1, uresult.getAlias(), &ec);
     67  * if (U_FAILURE(ec)) { return; }
     68  *
     69  * // Get the location of the percent sign:
     70  * UFieldPosition ufpos = {UNUM_PERCENT_FIELD, 0, 0};
     71  * unumf_resultNextFieldPosition(uresult.getAlias(), &ufpos, &ec);
     72  * // ufpos should contain beginIndex=7 and endIndex=8 since the string is "0.00987%"
     73  *
     74  * // No need to do any cleanup since we are using LocalPointer.
     75  * </pre>
     76  */
     77 
     78 
     79 #ifndef U_HIDE_DRAFT_API
     80 /**
     81  * An enum declaring how to render units, including currencies. Example outputs when formatting 123 USD and 123
     82  * meters in <em>en-CA</em>:
     83  *
     84  * <p>
     85  * <ul>
     86  * <li>NARROW*: "$123.00" and "123 m"
     87  * <li>SHORT: "US$123.00" and "123 m"
     88  * <li>FULL_NAME: "123.00 US dollars" and "123 meters"
     89  * <li>ISO_CODE: "USD123.00" and undefined behavior
     90  * <li>HIDDEN: "123.00" and "123"
     91  * </ul>
     92  *
     93  * <p>
     94  * This enum is similar to {@link UMeasureFormatWidth}.
     95  *
     96  * @draft ICU 60
     97  */
     98 typedef enum UNumberUnitWidth {
     99     /**
    100      * Print an abbreviated version of the unit name. Similar to SHORT, but always use the shortest available
    101      * abbreviation or symbol. This option can be used when the context hints at the identity of the unit. For more
    102      * information on the difference between NARROW and SHORT, see SHORT.
    103      *
    104      * <p>
    105      * In CLDR, this option corresponds to the "Narrow" format for measure units and the "" placeholder for
    106      * currencies.
    107      *
    108      * @draft ICU 60
    109      */
    110             UNUM_UNIT_WIDTH_NARROW,
    111 
    112     /**
    113      * Print an abbreviated version of the unit name. Similar to NARROW, but use a slightly wider abbreviation or
    114      * symbol when there may be ambiguity. This is the default behavior.
    115      *
    116      * <p>
    117      * For example, in <em>es-US</em>, the SHORT form for Fahrenheit is "{0} F", but the NARROW form is "{0}",
    118      * since Fahrenheit is the customary unit for temperature in that locale.
    119      *
    120      * <p>
    121      * In CLDR, this option corresponds to the "Short" format for measure units and the "" placeholder for
    122      * currencies.
    123      *
    124      * @draft ICU 60
    125      */
    126             UNUM_UNIT_WIDTH_SHORT,
    127 
    128     /**
    129      * Print the full name of the unit, without any abbreviations.
    130      *
    131      * <p>
    132      * In CLDR, this option corresponds to the default format for measure units and the "" placeholder for
    133      * currencies.
    134      *
    135      * @draft ICU 60
    136      */
    137             UNUM_UNIT_WIDTH_FULL_NAME,
    138 
    139     /**
    140      * Use the three-digit ISO XXX code in place of the symbol for displaying currencies. The behavior of this
    141      * option is currently undefined for use with measure units.
    142      *
    143      * <p>
    144      * In CLDR, this option corresponds to the "" placeholder for currencies.
    145      *
    146      * @draft ICU 60
    147      */
    148             UNUM_UNIT_WIDTH_ISO_CODE,
    149 
    150     /**
    151      * Format the number according to the specified unit, but do not display the unit. For currencies, apply
    152      * monetary symbols and formats as with SHORT, but omit the currency symbol. For measure units, the behavior is
    153      * equivalent to not specifying the unit at all.
    154      *
    155      * @draft ICU 60
    156      */
    157             UNUM_UNIT_WIDTH_HIDDEN,
    158 
    159     /**
    160      * One more than the highest UNumberUnitWidth value.
    161      *
    162      * @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
    163      */
    164             UNUM_UNIT_WIDTH_COUNT
    165 } UNumberUnitWidth;
    166 #endif  /* U_HIDE_DRAFT_API */
    167 
    168 #ifndef U_HIDE_DRAFT_API
    169 /**
    170  * An enum declaring the strategy for when and how to display grouping separators (i.e., the
    171  * separator, often a comma or period, after every 2-3 powers of ten). The choices are several
    172  * pre-built strategies for different use cases that employ locale data whenever possible. Example
    173  * outputs for 1234 and 1234567 in <em>en-IN</em>:
    174  *
    175  * <ul>
    176  * <li>OFF: 1234 and 12345
    177  * <li>MIN2: 1234 and 12,34,567
    178  * <li>AUTO: 1,234 and 12,34,567
    179  * <li>ON_ALIGNED: 1,234 and 12,34,567
    180  * <li>THOUSANDS: 1,234 and 1,234,567
    181  * </ul>
    182  *
    183  * <p>
    184  * The default is AUTO, which displays grouping separators unless the locale data says that grouping
    185  * is not customary. To force grouping for all numbers greater than 1000 consistently across locales,
    186  * use ON_ALIGNED. On the other hand, to display grouping less frequently than the default, use MIN2
    187  * or OFF. See the docs of each option for details.
    188  *
    189  * <p>
    190  * Note: This enum specifies the strategy for grouping sizes. To set which character to use as the
    191  * grouping separator, use the "symbols" setter.
    192  *
    193  * @draft ICU 63
    194  */
    195 typedef enum UNumberGroupingStrategy {
    196     /**
    197      * Do not display grouping separators in any locale.
    198      *
    199      * @draft ICU 61
    200      */
    201             UNUM_GROUPING_OFF,
    202 
    203     /**
    204      * Display grouping using locale defaults, except do not show grouping on values smaller than
    205      * 10000 (such that there is a <em>minimum of two digits</em> before the first separator).
    206      *
    207      * <p>
    208      * Note that locales may restrict grouping separators to be displayed only on 1 million or
    209      * greater (for example, ee and hu) or disable grouping altogether (for example, bg currency).
    210      *
    211      * <p>
    212      * Locale data is used to determine whether to separate larger numbers into groups of 2
    213      * (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
    214      *
    215      * @draft ICU 61
    216      */
    217             UNUM_GROUPING_MIN2,
    218 
    219     /**
    220      * Display grouping using the default strategy for all locales. This is the default behavior.
    221      *
    222      * <p>
    223      * Note that locales may restrict grouping separators to be displayed only on 1 million or
    224      * greater (for example, ee and hu) or disable grouping altogether (for example, bg currency).
    225      *
    226      * <p>
    227      * Locale data is used to determine whether to separate larger numbers into groups of 2
    228      * (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
    229      *
    230      * @draft ICU 61
    231      */
    232             UNUM_GROUPING_AUTO,
    233 
    234     /**
    235      * Always display the grouping separator on values of at least 1000.
    236      *
    237      * <p>
    238      * This option ignores the locale data that restricts or disables grouping, described in MIN2 and
    239      * AUTO. This option may be useful to normalize the alignment of numbers, such as in a
    240      * spreadsheet.
    241      *
    242      * <p>
    243      * Locale data is used to determine whether to separate larger numbers into groups of 2
    244      * (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
    245      *
    246      * @draft ICU 61
    247      */
    248             UNUM_GROUPING_ON_ALIGNED,
    249 
    250     /**
    251      * Use the Western defaults: groups of 3 and enabled for all numbers 1000 or greater. Do not use
    252      * locale data for determining the grouping strategy.
    253      *
    254      * @draft ICU 61
    255      */
    256             UNUM_GROUPING_THOUSANDS
    257 
    258 #ifndef U_HIDE_INTERNAL_API
    259     ,
    260     /**
    261      * One more than the highest UNumberGroupingStrategy value.
    262      *
    263      * @internal ICU 62: The numeric value may change over time; see ICU ticket #12420.
    264      */
    265             UNUM_GROUPING_COUNT
    266 #endif  /* U_HIDE_INTERNAL_API */
    267 
    268 } UNumberGroupingStrategy;
    269 
    270 #ifndef U_HIDE_DEPRECATED_API
    271 /**
    272  * Old name for compatibility: will be removed in ICU 64.
    273  * @deprecated ICU 63
    274  */
    275 typedef UNumberGroupingStrategy UGroupingStrategy;
    276 #endif  /* U_HIDE_DEPRECATED_API */
    277 
    278 #endif  /* U_HIDE_DRAFT_API */
    279 
    280 #ifndef U_HIDE_DRAFT_API
    281 /**
    282  * An enum declaring how to denote positive and negative numbers. Example outputs when formatting
    283  * 123, 0, and -123 in <em>en-US</em>:
    284  *
    285  * <ul>
    286  * <li>AUTO: "123", "0", and "-123"
    287  * <li>ALWAYS: "+123", "+0", and "-123"
    288  * <li>NEVER: "123", "0", and "123"
    289  * <li>ACCOUNTING: "$123", "$0", and "($123)"
    290  * <li>ACCOUNTING_ALWAYS: "+$123", "+$0", and "($123)"
    291  * <li>EXCEPT_ZERO: "+123", "0", and "-123"
    292  * <li>ACCOUNTING_EXCEPT_ZERO: "+$123", "$0", and "($123)"
    293  * </ul>
    294  *
    295  * <p>
    296  * The exact format, including the position and the code point of the sign, differ by locale.
    297  *
    298  * @draft ICU 60
    299  */
    300 typedef enum UNumberSignDisplay {
    301     /**
    302      * Show the minus sign on negative numbers, and do not show the sign on positive numbers. This is the default
    303      * behavior.
    304      *
    305      * @draft ICU 60
    306      */
    307             UNUM_SIGN_AUTO,
    308 
    309     /**
    310      * Show the minus sign on negative numbers and the plus sign on positive numbers, including zero.
    311      * To hide the sign on zero, see {@link UNUM_SIGN_EXCEPT_ZERO}.
    312      *
    313      * @draft ICU 60
    314      */
    315             UNUM_SIGN_ALWAYS,
    316 
    317     /**
    318      * Do not show the sign on positive or negative numbers.
    319      *
    320      * @draft ICU 60
    321      */
    322             UNUM_SIGN_NEVER,
    323 
    324     /**
    325      * Use the locale-dependent accounting format on negative numbers, and do not show the sign on positive numbers.
    326      *
    327      * <p>
    328      * The accounting format is defined in CLDR and varies by locale; in many Western locales, the format is a pair
    329      * of parentheses around the number.
    330      *
    331      * <p>
    332      * Note: Since CLDR defines the accounting format in the monetary context only, this option falls back to the
    333      * AUTO sign display strategy when formatting without a currency unit. This limitation may be lifted in the
    334      * future.
    335      *
    336      * @draft ICU 60
    337      */
    338             UNUM_SIGN_ACCOUNTING,
    339 
    340     /**
    341      * Use the locale-dependent accounting format on negative numbers, and show the plus sign on
    342      * positive numbers, including zero. For more information on the accounting format, see the
    343      * ACCOUNTING sign display strategy. To hide the sign on zero, see
    344      * {@link UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO}.
    345      *
    346      * @draft ICU 60
    347      */
    348             UNUM_SIGN_ACCOUNTING_ALWAYS,
    349 
    350     /**
    351      * Show the minus sign on negative numbers and the plus sign on positive numbers. Do not show a
    352      * sign on zero.
    353      *
    354      * @draft ICU 61
    355      */
    356             UNUM_SIGN_EXCEPT_ZERO,
    357 
    358     /**
    359      * Use the locale-dependent accounting format on negative numbers, and show the plus sign on
    360      * positive numbers. Do not show a sign on zero. For more information on the accounting format,
    361      * see the ACCOUNTING sign display strategy.
    362      *
    363      * @draft ICU 61
    364      */
    365             UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO,
    366 
    367     /**
    368      * One more than the highest UNumberSignDisplay value.
    369      *
    370      * @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
    371      */
    372             UNUM_SIGN_COUNT
    373 } UNumberSignDisplay;
    374 #endif  /* U_HIDE_DRAFT_API */
    375 
    376 #ifndef U_HIDE_DRAFT_API
    377 /**
    378  * An enum declaring how to render the decimal separator.
    379  *
    380  * <p>
    381  * <ul>
    382  * <li>UNUM_DECIMAL_SEPARATOR_AUTO: "1", "1.1"
    383  * <li>UNUM_DECIMAL_SEPARATOR_ALWAYS: "1.", "1.1"
    384  * </ul>
    385  */
    386 typedef enum UNumberDecimalSeparatorDisplay {
    387     /**
    388      * Show the decimal separator when there are one or more digits to display after the separator, and do not show
    389      * it otherwise. This is the default behavior.
    390      *
    391      * @draft ICU 60
    392      */
    393             UNUM_DECIMAL_SEPARATOR_AUTO,
    394 
    395     /**
    396      * Always show the decimal separator, even if there are no digits to display after the separator.
    397      *
    398      * @draft ICU 60
    399      */
    400             UNUM_DECIMAL_SEPARATOR_ALWAYS,
    401 
    402     /**
    403      * One more than the highest UNumberDecimalSeparatorDisplay value.
    404      *
    405      * @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
    406      */
    407             UNUM_DECIMAL_SEPARATOR_COUNT
    408 } UNumberDecimalSeparatorDisplay;
    409 #endif  /* U_HIDE_DRAFT_API */
    410 
    411 #ifndef U_HIDE_DRAFT_API
    412 
    413 struct UNumberFormatter;
    414 /**
    415  * C-compatible version of icu::number::LocalizedNumberFormatter.
    416  *
    417  * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
    418  *
    419  * @draft ICU 62
    420  */
    421 typedef struct UNumberFormatter UNumberFormatter;
    422 
    423 struct UFormattedNumber;
    424 /**
    425  * C-compatible version of icu::number::FormattedNumber.
    426  *
    427  * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
    428  *
    429  * @draft ICU 62
    430  */
    431 typedef struct UFormattedNumber UFormattedNumber;
    432 
    433 
    434 /**
    435  * Creates a new UNumberFormatter for the given skeleton string and locale. This is currently the only
    436  * method for creating a new UNumberFormatter.
    437  *
    438  * Objects of type UNumberFormatter returned by this method are threadsafe.
    439  *
    440  * For more details on skeleton strings, see the documentation in numberformatter.h. For more details on
    441  * the usage of this API, see the documentation at the top of unumberformatter.h.
    442  *
    443  * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
    444  *
    445  * @param skeleton The skeleton string, like u"percent precision-integer"
    446  * @param skeletonLen The number of UChars in the skeleton string, or -1 it it is NUL-terminated.
    447  * @param locale The NUL-terminated locale ID.
    448  * @param ec Set if an error occurs.
    449  * @draft ICU 62
    450  */
    451 U_DRAFT UNumberFormatter* U_EXPORT2
    452 unumf_openForSkeletonAndLocale(const UChar* skeleton, int32_t skeletonLen, const char* locale,
    453                                UErrorCode* ec);
    454 
    455 
    456 /**
    457  * Creates a new UFormattedNumber for holding the result of a number formatting operation.
    458  *
    459  * Objects of type UFormattedNumber are not guaranteed to be threadsafe.
    460  *
    461  * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
    462  *
    463  * @param ec Set if an error occurs.
    464  * @draft ICU 62
    465  */
    466 U_DRAFT UFormattedNumber* U_EXPORT2
    467 unumf_openResult(UErrorCode* ec);
    468 
    469 
    470 /**
    471  * Uses a UNumberFormatter to format an integer to a UFormattedNumber. A string, field position, and other
    472  * information can be retrieved from the UFormattedNumber.
    473  *
    474  * The UNumberFormatter can be shared between threads. Each thread should have its own local
    475  * UFormattedNumber, however, for storing the result of the formatting operation.
    476  *
    477  * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
    478  *
    479  * @param uformatter A formatter object created by unumf_openForSkeletonAndLocale or similar.
    480  * @param value The number to be formatted.
    481  * @param uresult The object that will be mutated to store the result; see unumf_openResult.
    482  * @param ec Set if an error occurs.
    483  * @draft ICU 62
    484  */
    485 U_DRAFT void U_EXPORT2
    486 unumf_formatInt(const UNumberFormatter* uformatter, int64_t value, UFormattedNumber* uresult,
    487                 UErrorCode* ec);
    488 
    489 
    490 /**
    491  * Uses a UNumberFormatter to format a double to a UFormattedNumber. A string, field position, and other
    492  * information can be retrieved from the UFormattedNumber.
    493  *
    494  * The UNumberFormatter can be shared between threads. Each thread should have its own local
    495  * UFormattedNumber, however, for storing the result of the formatting operation.
    496  *
    497  * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
    498  *
    499  * @param uformatter A formatter object created by unumf_openForSkeletonAndLocale or similar.
    500  * @param value The number to be formatted.
    501  * @param uresult The object that will be mutated to store the result; see unumf_openResult.
    502  * @param ec Set if an error occurs.
    503  * @draft ICU 62
    504  */
    505 U_DRAFT void U_EXPORT2
    506 unumf_formatDouble(const UNumberFormatter* uformatter, double value, UFormattedNumber* uresult,
    507                    UErrorCode* ec);
    508 
    509 
    510 /**
    511  * Uses a UNumberFormatter to format a decimal number to a UFormattedNumber. A string, field position, and
    512  * other information can be retrieved from the UFormattedNumber.
    513  *
    514  * The UNumberFormatter can be shared between threads. Each thread should have its own local
    515  * UFormattedNumber, however, for storing the result of the formatting operation.
    516  *
    517  * The syntax of the unformatted number is a "numeric string" as defined in the Decimal Arithmetic
    518  * Specification, available at http://speleotrove.com/decimal
    519  *
    520  * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
    521  *
    522  * @param uformatter A formatter object created by unumf_openForSkeletonAndLocale or similar.
    523  * @param value The numeric string to be formatted.
    524  * @param valueLen The length of the numeric string, or -1 if it is NUL-terminated.
    525  * @param uresult The object that will be mutated to store the result; see unumf_openResult.
    526  * @param ec Set if an error occurs.
    527  * @draft ICU 62
    528  */
    529 U_DRAFT void U_EXPORT2
    530 unumf_formatDecimal(const UNumberFormatter* uformatter, const char* value, int32_t valueLen,
    531                     UFormattedNumber* uresult, UErrorCode* ec);
    532 
    533 
    534 /**
    535  * Extracts the result number string out of a UFormattedNumber to a UChar buffer if possible.
    536  * If bufferCapacity is greater than the required length, a terminating NUL is written.
    537  * If bufferCapacity is less than the required length, an error code is set.
    538  *
    539  * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
    540  *
    541  * @param uresult The object containing the formatted number.
    542  * @param buffer Where to save the string output.
    543  * @param bufferCapacity The number of UChars available in the buffer.
    544  * @param ec Set if an error occurs.
    545  * @return The required length.
    546  * @draft ICU 62
    547  */
    548 U_DRAFT int32_t U_EXPORT2
    549 unumf_resultToString(const UFormattedNumber* uresult, UChar* buffer, int32_t bufferCapacity,
    550                      UErrorCode* ec);
    551 
    552 
    553 /**
    554  * Determines the start and end indices of the next occurrence of the given <em>field</em> in the
    555  * output string. This allows you to determine the locations of, for example, the integer part,
    556  * fraction part, or symbols.
    557  *
    558  * If a field occurs just once, calling this method will find that occurrence and return it. If a
    559  * field occurs multiple times, this method may be called repeatedly with the following pattern:
    560  *
    561  * <pre>
    562  * UFieldPosition ufpos = {UNUM_GROUPING_SEPARATOR_FIELD, 0, 0};
    563  * while (unumf_resultNextFieldPosition(uresult, ufpos, &ec)) {
    564  *   // do something with ufpos.
    565  * }
    566  * </pre>
    567  *
    568  * This method is useful if you know which field to query. If you want all available field position
    569  * information, use unumf_resultGetAllFieldPositions().
    570  *
    571  * NOTE: All fields of the UFieldPosition must be initialized before calling this method.
    572  *
    573  * @param uresult The object containing the formatted number.
    574  * @param ufpos
    575  *            Input+output variable. On input, the "field" property determines which field to look up,
    576  *            and the "endIndex" property determines where to begin the search. On output, the
    577  *            "beginIndex" field is set to the beginning of the first occurrence of the field after the
    578  *            input "endIndex", and "endIndex" is set to the end of that occurrence of the field
    579  *            (exclusive index). If a field position is not found, the FieldPosition is not changed and
    580  *            the method returns FALSE.
    581  * @param ec Set if an error occurs.
    582  * @draft ICU 62
    583  */
    584 U_DRAFT UBool U_EXPORT2
    585 unumf_resultNextFieldPosition(const UFormattedNumber* uresult, UFieldPosition* ufpos, UErrorCode* ec);
    586 
    587 
    588 /**
    589  * Populates the given iterator with all fields in the formatted output string. This allows you to
    590  * determine the locations of the integer part, fraction part, and sign.
    591  *
    592  * If you need information on only one field, use unumf_resultNextFieldPosition().
    593  *
    594  * @param uresult The object containing the formatted number.
    595  * @param ufpositer
    596  *         A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open}. Iteration
    597  *         information already present in the UFieldPositionIterator is deleted, and the iterator is reset
    598  *         to apply to the fields in the formatted string created by this function call. The field values
    599  *         and indexes returned by {@link #ufieldpositer_next} represent fields denoted by
    600  *         the UNumberFormatFields enum. Fields are not returned in a guaranteed order. Fields cannot
    601  *         overlap, but they may nest. For example, 1234 could format as "1,234" which might consist of a
    602  *         grouping separator field for ',' and an integer field encompassing the entire string.
    603  * @param ec Set if an error occurs.
    604  * @draft ICU 62
    605  */
    606 U_DRAFT void U_EXPORT2
    607 unumf_resultGetAllFieldPositions(const UFormattedNumber* uresult, UFieldPositionIterator* ufpositer,
    608                                  UErrorCode* ec);
    609 
    610 
    611 /**
    612  * Releases the UNumberFormatter created by unumf_openForSkeletonAndLocale().
    613  *
    614  * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
    615  *
    616  * @param uformatter An object created by unumf_openForSkeletonAndLocale().
    617  * @draft ICU 62
    618  */
    619 U_DRAFT void U_EXPORT2
    620 unumf_close(UNumberFormatter* uformatter);
    621 
    622 
    623 /**
    624  * Releases the UFormattedNumber created by unumf_openResult().
    625  *
    626  * NOTE: This is a C-compatible API; C++ users should build against numberformatter.h instead.
    627  *
    628  * @param uresult An object created by unumf_openResult().
    629  * @draft ICU 62
    630  */
    631 U_DRAFT void U_EXPORT2
    632 unumf_closeResult(UFormattedNumber* uresult);
    633 
    634 
    635 #if U_SHOW_CPLUSPLUS_API
    636 U_NAMESPACE_BEGIN
    637 
    638 /**
    639  * \class LocalUNumberFormatterPointer
    640  * "Smart pointer" class; closes a UNumberFormatter via unumf_close().
    641  * For most methods see the LocalPointerBase base class.
    642  *
    643  * Usage:
    644  * <pre>
    645  * LocalUNumberFormatterPointer uformatter(unumf_openForSkeletonAndLocale(...));
    646  * // no need to explicitly call unumf_close()
    647  * </pre>
    648  *
    649  * @see LocalPointerBase
    650  * @see LocalPointer
    651  * @draft ICU 62
    652  */
    653 U_DEFINE_LOCAL_OPEN_POINTER(LocalUNumberFormatterPointer, UNumberFormatter, unumf_close);
    654 
    655 /**
    656  * \class LocalUNumberFormatterPointer
    657  * "Smart pointer" class; closes a UFormattedNumber via unumf_closeResult().
    658  * For most methods see the LocalPointerBase base class.
    659  *
    660  * Usage:
    661  * <pre>
    662  * LocalUFormattedNumberPointer uformatter(unumf_openResult(...));
    663  * // no need to explicitly call unumf_closeResult()
    664  * </pre>
    665  *
    666  * @see LocalPointerBase
    667  * @see LocalPointer
    668  * @draft ICU 62
    669  */
    670 U_DEFINE_LOCAL_OPEN_POINTER(LocalUFormattedNumberPointer, UFormattedNumber, unumf_closeResult);
    671 
    672 U_NAMESPACE_END
    673 #endif // U_SHOW_CPLUSPLUS_API
    674 
    675 #endif  /* U_HIDE_DRAFT_API */
    676 
    677 #endif //__UNUMBERFORMATTER_H__
    678 #endif /* #if !UCONFIG_NO_FORMATTING */
    679 
    680 
    681 
    682 
    683 
    684 
    685 
    686 
    687 
    688 
    689 
    690 
    691 
    692 
    693 
    694 
    695 
    696 
    697 
    698 
    699 
    700 
    701 
    702 
    703 
    704 
    705 
    706 
    707 
    708 
    709 
    710 
    711 
    712 
    713 
    714 
    715 
    716 
    717 
    718 
    719 
    720 
    721 
    722 
    723 
    724 
    725 
    726 
    727 
    728 
    729 
    730