1 // © 2017 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 #include "unicode/utypes.h"
6 #if !UCONFIG_NO_FORMATTING
7 #ifndef __NUMBERFORMATTER_H__
8 #define __NUMBERFORMATTER_H__
10 #include "unicode/appendable.h"
11 #include "unicode/dcfmtsym.h"
12 #include "unicode/currunit.h"
13 #include "unicode/fieldpos.h"
14 #include "unicode/fpositer.h"
15 #include "unicode/measunit.h"
16 #include "unicode/nounit.h"
17 #include "unicode/plurrule.h"
18 #include "unicode/ucurr.h"
19 #include "unicode/unum.h"
20 #include "unicode/unumberformatter.h"
21 #include "unicode/uobject.h"
23 #ifndef U_HIDE_DRAFT_API
27 * \brief C++ API: Library for localized number formatting introduced in ICU 60.
29 * This library was introduced in ICU 60 to simplify the process of formatting localized number strings.
30 * Basic usage examples:
33 * // Most basic usage:
34 * NumberFormatter::withLocale(...).format(123).toString(); // 1,234 in en-US
36 * // Custom notation, unit, and rounding precision:
37 * NumberFormatter::with()
38 * .notation(Notation::compactShort())
39 * .unit(CurrencyUnit("EUR", status))
40 * .precision(Precision::maxDigits(2))
43 * .toString(); // €1.2K in en-US
45 * // Create a formatter in a singleton for use later:
46 * static const LocalizedNumberFormatter formatter = NumberFormatter::withLocale(...)
47 * .unit(NoUnit::percent())
48 * .precision(Precision::fixedFraction(3));
49 * formatter.format(5.9831).toString(); // 5.983% in en-US
51 * // Create a "template" in a singleton but without setting a locale until the call site:
52 * static const UnlocalizedNumberFormatter template = NumberFormatter::with()
53 * .sign(UNumberSignDisplay::UNUM_SIGN_ALWAYS)
54 * .adoptUnit(MeasureUnit::createMeter(status))
55 * .unitWidth(UNumberUnitWidth::UNUM_UNIT_WIDTH_FULL_NAME);
56 * template.locale(...).format(1234).toString(); // +1,234 meters in en-US
60 * This API offers more features than DecimalFormat and is geared toward new users of ICU.
63 * NumberFormatter instances are immutable and thread safe. This means that invoking a configuration method has no
64 * effect on the receiving instance; you must store and use the new number formatter instance it returns instead.
67 * UnlocalizedNumberFormatter formatter = UnlocalizedNumberFormatter::with().notation(Notation::scientific());
68 * formatter.precision(Precision.maxFraction(2)); // does nothing!
69 * formatter.locale(Locale.getEnglish()).format(9.8765).toString(); // prints "9.8765E0", not "9.88E0"
73 * This API is based on the <em>fluent</em> design pattern popularized by libraries such as Google's Guava. For
74 * extensive details on the design of this API, read <a href="https://goo.gl/szi5VB">the design doc</a>.
81 // Forward declarations:
83 class FieldPositionIteratorHandler
;
88 // Forward declarations:
89 class NumberParserImpl
;
90 class MultiplierParseHandler
;
95 namespace number
{ // icu::number
97 // Forward declarations:
98 class UnlocalizedNumberFormatter
;
99 class LocalizedNumberFormatter
;
100 class FormattedNumber
;
102 class ScientificNotation
;
104 class FractionPrecision
;
105 class CurrencyPrecision
;
106 class IncrementPrecision
;
112 * Datatype for minimum/maximum fraction digits. Must be able to hold kMaxIntFracSig.
116 typedef int16_t digits_t
;
119 * Use a default threshold of 3. This means that the third time .format() is called, the data structures get built
120 * using the "safe" code path. The first two calls to .format() will trigger the unsafe code path.
124 static constexpr int32_t DEFAULT_THRESHOLD
= 3;
126 // Forward declarations:
130 class DecimalQuantity
;
131 struct UFormattedNumberData
;
132 class NumberFormatterImpl
;
133 struct ParsedPatternInfo
;
134 class ScientificModifier
;
135 class MultiplierProducer
;
137 class ScientificHandler
;
139 class NumberStringBuilder
;
140 class AffixPatternProvider
;
141 class NumberPropertyMapper
;
142 struct DecimalFormatProperties
;
143 class MultiplierFormatHandler
;
144 class CurrencySymbols
;
145 class GeneratorHelpers
;
150 // Reserve extra names in case they are added as classes in the future:
151 typedef Notation CompactNotation
;
152 typedef Notation SimpleNotation
;
155 * A class that defines the notation style to be used when formatting numbers in NumberFormatter.
159 class U_I18N_API Notation
: public UMemory
{
162 * Print the number using scientific notation (also known as scientific form, standard index form, or standard form
163 * in the UK). The format for scientific notation varies by locale; for example, many Western locales display the
164 * number in the form "#E0", where the number is displayed with one digit before the decimal separator, zero or more
165 * digits after the decimal separator, and the corresponding power of 10 displayed after the "E".
168 * Example outputs in <em>en-US</em> when printing 8.765E4 through 8.765E-3:
182 * @return A ScientificNotation for chaining or passing to the NumberFormatter notation() setter.
185 static ScientificNotation
scientific();
188 * Print the number using engineering notation, a variant of scientific notation in which the exponent must be
192 * Example outputs in <em>en-US</em> when printing 8.765E4 through 8.765E-3:
206 * @return A ScientificNotation for chaining or passing to the NumberFormatter notation() setter.
209 static ScientificNotation
engineering();
212 * Print the number using short-form compact notation.
215 * <em>Compact notation</em>, defined in Unicode Technical Standard #35 Part 3 Section 2.4.1, prints numbers with
216 * localized prefixes or suffixes corresponding to different powers of ten. Compact notation is similar to
217 * engineering notation in how it scales numbers.
220 * Compact notation is ideal for displaying large numbers (over ~1000) to humans while at the same time minimizing
221 * screen real estate.
224 * In short form, the powers of ten are abbreviated. In <em>en-US</em>, the abbreviations are "K" for thousands, "M"
225 * for millions, "B" for billions, and "T" for trillions. Example outputs in <em>en-US</em> when printing 8.765E7
240 * When compact notation is specified without an explicit rounding precision, numbers are rounded off to the closest
241 * integer after scaling the number by the corresponding power of 10, but with a digit shown after the decimal
242 * separator if there is only one digit before the decimal separator. The default compact notation rounding precision
246 * Precision::integer().withMinDigits(2)
249 * @return A CompactNotation for passing to the NumberFormatter notation() setter.
252 static CompactNotation
compactShort();
255 * Print the number using long-form compact notation. For more information on compact notation, see
256 * {@link #compactShort}.
259 * In long form, the powers of ten are spelled out fully. Example outputs in <em>en-US</em> when printing 8.765E7
273 * @return A CompactNotation for passing to the NumberFormatter notation() setter.
276 static CompactNotation
compactLong();
279 * Print the number using simple notation without any scaling by powers of ten. This is the default behavior.
282 * Since this is the default behavior, this method needs to be called only when it is necessary to override a
286 * Example outputs in <em>en-US</em> when printing 8.765E7 through 8.765E0:
299 * @return A SimpleNotation for passing to the NumberFormatter notation() setter.
302 static SimpleNotation
simple();
306 NTN_SCIENTIFIC
, NTN_COMPACT
, NTN_SIMPLE
, NTN_ERROR
309 union NotationUnion
{
310 // For NTN_SCIENTIFIC
311 struct ScientificSettings
{
312 int8_t fEngineeringInterval
;
314 impl::digits_t fMinExponentDigits
;
315 UNumberSignDisplay fExponentSignDisplay
;
319 UNumberCompactStyle compactStyle
;
322 UErrorCode errorCode
;
325 typedef NotationUnion::ScientificSettings ScientificSettings
;
327 Notation(const NotationType
&type
, const NotationUnion
&union_
) : fType(type
), fUnion(union_
) {}
329 Notation(UErrorCode errorCode
) : fType(NTN_ERROR
) {
330 fUnion
.errorCode
= errorCode
;
333 Notation() : fType(NTN_SIMPLE
), fUnion() {}
335 UBool
copyErrorTo(UErrorCode
&status
) const {
336 if (fType
== NTN_ERROR
) {
337 status
= fUnion
.errorCode
;
343 // To allow MacroProps to initialize empty instances:
344 friend struct impl::MacroProps
;
345 friend class ScientificNotation
;
347 // To allow implementation to access internal types:
348 friend class impl::NumberFormatterImpl
;
349 friend class impl::ScientificModifier
;
350 friend class impl::ScientificHandler
;
352 // To allow access to the skeleton generation code:
353 friend class impl::GeneratorHelpers
;
357 * A class that defines the scientific notation style to be used when formatting numbers in NumberFormatter.
360 * To create a ScientificNotation, use one of the factory methods in {@link Notation}.
364 class U_I18N_API ScientificNotation
: public Notation
{
367 * Sets the minimum number of digits to show in the exponent of scientific notation, padding with zeros if
368 * necessary. Useful for fixed-width display.
371 * For example, with minExponentDigits=2, the number 123 will be printed as "1.23E02" in <em>en-US</em> instead of
372 * the default "1.23E2".
374 * @param minExponentDigits
375 * The minimum number of digits to show in the exponent.
376 * @return A ScientificNotation, for chaining.
379 ScientificNotation
withMinExponentDigits(int32_t minExponentDigits
) const;
382 * Sets whether to show the sign on positive and negative exponents in scientific notation. The default is AUTO,
383 * showing the minus sign but not the plus sign.
386 * For example, with exponentSignDisplay=ALWAYS, the number 123 will be printed as "1.23E+2" in <em>en-US</em>
387 * instead of the default "1.23E2".
389 * @param exponentSignDisplay
390 * The strategy for displaying the sign in the exponent.
391 * @return A ScientificNotation, for chaining.
394 ScientificNotation
withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay
) const;
397 // Inherit constructor
398 using Notation::Notation
;
400 // Raw constructor for NumberPropertyMapper
401 ScientificNotation(int8_t fEngineeringInterval
, bool fRequireMinInt
, impl::digits_t fMinExponentDigits
,
402 UNumberSignDisplay fExponentSignDisplay
);
404 friend class Notation
;
406 // So that NumberPropertyMapper can create instances
407 friend class impl::NumberPropertyMapper
;
410 // Reserve extra names in case they are added as classes in the future:
411 typedef Precision SignificantDigitsPrecision
;
413 // Typedefs for ICU 60/61 compatibility.
414 // These will be removed in ICU 64.
415 // See http://bugs.icu-project.org/trac/ticket/13746
416 typedef Precision Rounder
;
417 typedef FractionPrecision FractionRounder
;
418 typedef IncrementPrecision IncrementRounder
;
419 typedef CurrencyPrecision CurrencyRounder
;
422 * A class that defines the rounding precision to be used when formatting numbers in NumberFormatter.
425 * To create a Precision, use one of the factory methods.
429 class U_I18N_API Precision
: public UMemory
{
433 * Show all available digits to full precision.
436 * <strong>NOTE:</strong> When formatting a <em>double</em>, this method, along with {@link #minFraction} and
437 * {@link #minDigits}, will trigger complex algorithm similar to <em>Dragon4</em> to determine the low-order digits
438 * and the number of digits to display based on the value of the double. If the number of fraction places or
439 * significant digits can be bounded, consider using {@link #maxFraction} or {@link #maxDigits} instead to maximize
440 * performance. For more information, read the following blog post.
443 * http://www.serpentine.com/blog/2011/06/29/here-be-dragons-advances-in-problems-you-didnt-even-know-you-had/
445 * @return A Precision for chaining or passing to the NumberFormatter precision() setter.
448 static Precision
unlimited();
451 * Show numbers rounded if necessary to the nearest integer.
453 * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.
456 static FractionPrecision
integer();
459 * Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator).
460 * Additionally, pad with zeros to ensure that this number of places are always shown.
463 * Example output with minMaxFractionPlaces = 3:
477 * This method is equivalent to {@link #minMaxFraction} with both arguments equal.
479 * @param minMaxFractionPlaces
480 * The minimum and maximum number of numerals to display after the decimal separator (rounding if too
481 * long or padding with zeros if too short).
482 * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.
485 static FractionPrecision
fixedFraction(int32_t minMaxFractionPlaces
);
488 * Always show at least a certain number of fraction places after the decimal separator, padding with zeros if
489 * necessary. Do not perform rounding (display numbers to their full precision).
492 * <strong>NOTE:</strong> If you are formatting <em>doubles</em>, see the performance note in {@link #unlimited}.
494 * @param minFractionPlaces
495 * The minimum number of numerals to display after the decimal separator (padding with zeros if
497 * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.
500 static FractionPrecision
minFraction(int32_t minFractionPlaces
);
503 * Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator).
504 * Unlike the other fraction rounding strategies, this strategy does <em>not</em> pad zeros to the end of the
507 * @param maxFractionPlaces
508 * The maximum number of numerals to display after the decimal mark (rounding if necessary).
509 * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.
512 static FractionPrecision
maxFraction(int32_t maxFractionPlaces
);
515 * Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator);
516 * in addition, always show at least a certain number of places after the decimal separator, padding with zeros if
519 * @param minFractionPlaces
520 * The minimum number of numerals to display after the decimal separator (padding with zeros if
522 * @param maxFractionPlaces
523 * The maximum number of numerals to display after the decimal separator (rounding if necessary).
524 * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.
527 static FractionPrecision
minMaxFraction(int32_t minFractionPlaces
, int32_t maxFractionPlaces
);
530 * Show numbers rounded if necessary to a certain number of significant digits or significant figures. Additionally,
531 * pad with zeros to ensure that this number of significant digits/figures are always shown.
534 * This method is equivalent to {@link #minMaxDigits} with both arguments equal.
536 * @param minMaxSignificantDigits
537 * The minimum and maximum number of significant digits to display (rounding if too long or padding with
538 * zeros if too short).
539 * @return A precision for chaining or passing to the NumberFormatter precision() setter.
542 static SignificantDigitsPrecision
fixedSignificantDigits(int32_t minMaxSignificantDigits
);
545 * Always show at least a certain number of significant digits/figures, padding with zeros if necessary. Do not
546 * perform rounding (display numbers to their full precision).
549 * <strong>NOTE:</strong> If you are formatting <em>doubles</em>, see the performance note in {@link #unlimited}.
551 * @param minSignificantDigits
552 * The minimum number of significant digits to display (padding with zeros if too short).
553 * @return A precision for chaining or passing to the NumberFormatter precision() setter.
556 static SignificantDigitsPrecision
minSignificantDigits(int32_t minSignificantDigits
);
559 * Show numbers rounded if necessary to a certain number of significant digits/figures.
561 * @param maxSignificantDigits
562 * The maximum number of significant digits to display (rounding if too long).
563 * @return A precision for chaining or passing to the NumberFormatter precision() setter.
566 static SignificantDigitsPrecision
maxSignificantDigits(int32_t maxSignificantDigits
);
569 * Show numbers rounded if necessary to a certain number of significant digits/figures; in addition, always show at
570 * least a certain number of significant digits, padding with zeros if necessary.
572 * @param minSignificantDigits
573 * The minimum number of significant digits to display (padding with zeros if necessary).
574 * @param maxSignificantDigits
575 * The maximum number of significant digits to display (rounding if necessary).
576 * @return A precision for chaining or passing to the NumberFormatter precision() setter.
579 static SignificantDigitsPrecision
minMaxSignificantDigits(int32_t minSignificantDigits
,
580 int32_t maxSignificantDigits
);
582 #ifndef U_HIDE_DEPRECATED_API
583 // Compatiblity methods that will be removed in ICU 64.
584 // See http://bugs.icu-project.org/trac/ticket/13746
586 /** @deprecated ICU 62 */
587 static inline SignificantDigitsPrecision
fixedDigits(int32_t a
) {
588 return fixedSignificantDigits(a
);
591 /** @deprecated ICU 62 */
592 static inline SignificantDigitsPrecision
minDigits(int32_t a
) {
593 return minSignificantDigits(a
);
596 /** @deprecated ICU 62 */
597 static inline SignificantDigitsPrecision
maxDigits(int32_t a
) {
598 return maxSignificantDigits(a
);
601 /** @deprecated ICU 62 */
602 static inline SignificantDigitsPrecision
minMaxDigits(int32_t a
, int32_t b
) {
603 return minMaxSignificantDigits(a
, b
);
605 #endif /* U_HIDE_DEPRECATED_API */
608 * Show numbers rounded if necessary to the closest multiple of a certain rounding increment. For example, if the
609 * rounding increment is 0.5, then round 1.2 to 1 and round 1.3 to 1.5.
612 * In order to ensure that numbers are padded to the appropriate number of fraction places, call
613 * withMinFraction() on the return value of this method.
614 * For example, to round to the nearest 0.5 and always display 2 numerals after the
615 * decimal separator (to display 1.2 as "1.00" and 1.3 as "1.50"), you can run:
618 * Precision::increment(0.5).withMinFraction(2)
621 * @param roundingIncrement
622 * The increment to which to round numbers.
623 * @return A precision for chaining or passing to the NumberFormatter precision() setter.
626 static IncrementPrecision
increment(double roundingIncrement
);
629 * Show numbers rounded and padded according to the rules for the currency unit. The most common
630 * rounding precision settings for currencies include <code>Precision::fixedFraction(2)</code>,
631 * <code>Precision::integer()</code>, and <code>Precision::increment(0.05)</code> for cash transactions
632 * ("nickel rounding").
635 * The exact rounding details will be resolved at runtime based on the currency unit specified in the
636 * NumberFormatter chain. To round according to the rules for one currency while displaying the symbol for another
637 * currency, the withCurrency() method can be called on the return value of this method.
639 * @param currencyUsage
640 * Either STANDARD (for digital transactions) or CASH (for transactions where the rounding increment may
641 * be limited by the available denominations of cash or coins).
642 * @return A CurrencyPrecision for chaining or passing to the NumberFormatter precision() setter.
645 static CurrencyPrecision
currency(UCurrencyUsage currencyUsage
);
647 #ifndef U_HIDE_DEPRECATED_API
649 * Sets the rounding mode to use when picking the direction to round (up or down). Common values
650 * include HALF_EVEN, HALF_UP, and FLOOR. The default is HALF_EVEN.
652 * @param roundingMode
653 * The RoundingMode to use.
654 * @return A Precision for passing to the NumberFormatter precision() setter.
655 * @deprecated ICU 62 Use the top-level roundingMode() setting instead.
656 * This method will be removed in ICU 64.
657 * See http://bugs.icu-project.org/trac/ticket/13746
659 Precision
withMode(UNumberFormatRoundingMode roundingMode
) const;
660 #endif /* U_HIDE_DEPRECATED_API */
668 RND_FRACTION_SIGNIFICANT
,
674 union PrecisionUnion
{
675 struct FractionSignificantSettings
{
676 // For RND_FRACTION, RND_SIGNIFICANT, and RND_FRACTION_SIGNIFICANT
677 impl::digits_t fMinFrac
;
678 impl::digits_t fMaxFrac
;
679 impl::digits_t fMinSig
;
680 impl::digits_t fMaxSig
;
682 struct IncrementSettings
{
684 impl::digits_t fMinFrac
;
685 impl::digits_t fMaxFrac
;
686 } increment
; // For RND_INCREMENT
687 UCurrencyUsage currencyUsage
; // For RND_CURRENCY
688 UErrorCode errorCode
; // For RND_ERROR
691 typedef PrecisionUnion::FractionSignificantSettings FractionSignificantSettings
;
692 typedef PrecisionUnion::IncrementSettings IncrementSettings
;
694 /** The Precision encapsulates the RoundingMode when used within the implementation. */
695 UNumberFormatRoundingMode fRoundingMode
;
697 Precision(const PrecisionType
& type
, const PrecisionUnion
& union_
,
698 UNumberFormatRoundingMode roundingMode
)
699 : fType(type
), fUnion(union_
), fRoundingMode(roundingMode
) {}
701 Precision(UErrorCode errorCode
) : fType(RND_ERROR
) {
702 fUnion
.errorCode
= errorCode
;
705 Precision() : fType(RND_BOGUS
) {}
707 bool isBogus() const {
708 return fType
== RND_BOGUS
;
711 UBool
copyErrorTo(UErrorCode
&status
) const {
712 if (fType
== RND_ERROR
) {
713 status
= fUnion
.errorCode
;
719 // On the parent type so that this method can be called internally on Precision instances.
720 Precision
withCurrency(const CurrencyUnit
¤cy
, UErrorCode
&status
) const;
722 static FractionPrecision
constructFraction(int32_t minFrac
, int32_t maxFrac
);
724 static Precision
constructSignificant(int32_t minSig
, int32_t maxSig
);
727 constructFractionSignificant(const FractionPrecision
&base
, int32_t minSig
, int32_t maxSig
);
729 static IncrementPrecision
constructIncrement(double increment
, int32_t minFrac
);
731 static CurrencyPrecision
constructCurrency(UCurrencyUsage usage
);
733 static Precision
constructPassThrough();
735 // To allow MacroProps/MicroProps to initialize bogus instances:
736 friend struct impl::MacroProps
;
737 friend struct impl::MicroProps
;
739 // To allow NumberFormatterImpl to access isBogus() and other internal methods:
740 friend class impl::NumberFormatterImpl
;
742 // To allow NumberPropertyMapper to create instances from DecimalFormatProperties:
743 friend class impl::NumberPropertyMapper
;
745 // To allow access to the main implementation class:
746 friend class impl::RoundingImpl
;
748 // To allow child classes to call private methods:
749 friend class FractionPrecision
;
750 friend class CurrencyPrecision
;
751 friend class IncrementPrecision
;
753 // To allow access to the skeleton generation code:
754 friend class impl::GeneratorHelpers
;
758 * A class that defines a rounding precision based on a number of fraction places and optionally significant digits to be
759 * used when formatting numbers in NumberFormatter.
762 * To create a FractionPrecision, use one of the factory methods on Precision.
766 class U_I18N_API FractionPrecision
: public Precision
{
769 * Ensure that no less than this number of significant digits are retained when rounding according to fraction
773 * For example, with integer rounding, the number 3.141 becomes "3". However, with minimum figures set to 2, 3.141
774 * becomes "3.1" instead.
777 * This setting does not affect the number of trailing zeros. For example, 3.01 would print as "3", not "3.0".
779 * @param minSignificantDigits
780 * The number of significant figures to guarantee.
781 * @return A precision for chaining or passing to the NumberFormatter precision() setter.
784 Precision
withMinDigits(int32_t minSignificantDigits
) const;
787 * Ensure that no more than this number of significant digits are retained when rounding according to fraction
791 * For example, with integer rounding, the number 123.4 becomes "123". However, with maximum figures set to 2, 123.4
792 * becomes "120" instead.
795 * This setting does not affect the number of trailing zeros. For example, with fixed fraction of 2, 123.4 would
798 * @param maxSignificantDigits
799 * Round the number to no more than this number of significant figures.
800 * @return A precision for chaining or passing to the NumberFormatter precision() setter.
803 Precision
withMaxDigits(int32_t maxSignificantDigits
) const;
806 // Inherit constructor
807 using Precision::Precision
;
809 // To allow parent class to call this class's constructor:
810 friend class Precision
;
814 * A class that defines a rounding precision parameterized by a currency to be used when formatting numbers in
818 * To create a CurrencyPrecision, use one of the factory methods on Precision.
822 class U_I18N_API CurrencyPrecision
: public Precision
{
825 * Associates a currency with this rounding precision.
828 * <strong>Calling this method is <em>not required</em></strong>, because the currency specified in unit()
829 * is automatically applied to currency rounding precisions. However,
830 * this method enables you to override that automatic association.
833 * This method also enables numbers to be formatted using currency rounding rules without explicitly using a
837 * The currency to associate with this rounding precision.
838 * @return A precision for chaining or passing to the NumberFormatter precision() setter.
841 Precision
withCurrency(const CurrencyUnit
¤cy
) const;
844 // Inherit constructor
845 using Precision::Precision
;
847 // To allow parent class to call this class's constructor:
848 friend class Precision
;
852 * A class that defines a rounding precision parameterized by a rounding increment to be used when formatting numbers in
856 * To create an IncrementPrecision, use one of the factory methods on Precision.
860 class U_I18N_API IncrementPrecision
: public Precision
{
863 * Specifies the minimum number of fraction digits to render after the decimal separator, padding with zeros if
864 * necessary. By default, no trailing zeros are added.
867 * For example, if the rounding increment is 0.5 and minFrac is 2, then the resulting strings include "0.00",
868 * "0.50", "1.00", and "1.50".
871 * Note: In ICU4J, this functionality is accomplished via the scale of the BigDecimal rounding increment.
873 * @param minFrac The minimum number of digits after the decimal separator.
874 * @return A precision for chaining or passing to the NumberFormatter precision() setter.
877 Precision
withMinFraction(int32_t minFrac
) const;
880 // Inherit constructor
881 using Precision::Precision
;
883 // To allow parent class to call this class's constructor:
884 friend class Precision
;
888 * A class that defines the strategy for padding and truncating integers before the decimal separator.
891 * To create an IntegerWidth, use one of the factory methods.
894 * @see NumberFormatter
896 class U_I18N_API IntegerWidth
: public UMemory
{
899 * Pad numbers at the beginning with zeros to guarantee a certain number of numerals before the decimal separator.
902 * For example, with minInt=3, the number 55 will get printed as "055".
905 * The minimum number of places before the decimal separator.
906 * @return An IntegerWidth for chaining or passing to the NumberFormatter integerWidth() setter.
909 static IntegerWidth
zeroFillTo(int32_t minInt
);
912 * Truncate numbers exceeding a certain number of numerals before the decimal separator.
914 * For example, with maxInt=3, the number 1234 will get printed as "234".
917 * The maximum number of places before the decimal separator. maxInt == -1 means no
919 * @return An IntegerWidth for passing to the NumberFormatter integerWidth() setter.
922 IntegerWidth
truncateAt(int32_t maxInt
);
927 impl::digits_t fMinInt
;
928 impl::digits_t fMaxInt
;
929 bool fFormatFailIfMoreThanMaxDigits
;
931 UErrorCode errorCode
;
933 bool fHasError
= false;
935 IntegerWidth(impl::digits_t minInt
, impl::digits_t maxInt
, bool formatFailIfMoreThanMaxDigits
);
937 IntegerWidth(UErrorCode errorCode
) { // NOLINT
938 fUnion
.errorCode
= errorCode
;
942 IntegerWidth() { // NOLINT
943 fUnion
.minMaxInt
.fMinInt
= -1;
946 /** Returns the default instance. */
947 static IntegerWidth
standard() {
948 return IntegerWidth::zeroFillTo(1);
951 bool isBogus() const {
952 return !fHasError
&& fUnion
.minMaxInt
.fMinInt
== -1;
955 UBool
copyErrorTo(UErrorCode
&status
) const {
957 status
= fUnion
.errorCode
;
963 void apply(impl::DecimalQuantity
&quantity
, UErrorCode
&status
) const;
965 bool operator==(const IntegerWidth
& other
) const;
967 // To allow MacroProps/MicroProps to initialize empty instances:
968 friend struct impl::MacroProps
;
969 friend struct impl::MicroProps
;
971 // To allow NumberFormatterImpl to access isBogus() and perform other operations:
972 friend class impl::NumberFormatterImpl
;
974 // So that NumberPropertyMapper can create instances
975 friend class impl::NumberPropertyMapper
;
977 // To allow access to the skeleton generation code:
978 friend class impl::GeneratorHelpers
;
982 * A class that defines a quantity by which a number should be multiplied when formatting.
985 * To create a Scale, use one of the factory methods.
989 class U_I18N_API Scale
: public UMemory
{
992 * Do not change the value of numbers when formatting or parsing.
994 * @return A Scale to prevent any multiplication.
1000 * Multiply numbers by a power of ten before formatting. Useful for combining with a percent unit:
1003 * NumberFormatter::with().unit(NoUnit::percent()).multiplier(Scale::powerOfTen(2))
1006 * @return A Scale for passing to the setter in NumberFormatter.
1009 static Scale
powerOfTen(int32_t power
);
1012 * Multiply numbers by an arbitrary value before formatting. Useful for unit conversions.
1014 * This method takes a string in a decimal number format with syntax
1015 * as defined in the Decimal Arithmetic Specification, available at
1016 * http://speleotrove.com/decimal
1018 * Also see the version of this method that takes a double.
1020 * @return A Scale for passing to the setter in NumberFormatter.
1023 static Scale
byDecimal(StringPiece multiplicand
);
1026 * Multiply numbers by an arbitrary value before formatting. Useful for unit conversions.
1028 * This method takes a double; also see the version of this method that takes an exact decimal.
1030 * @return A Scale for passing to the setter in NumberFormatter.
1033 static Scale
byDouble(double multiplicand
);
1036 * Multiply a number by both a power of ten and by an arbitrary double value.
1038 * @return A Scale for passing to the setter in NumberFormatter.
1041 static Scale
byDoubleAndPowerOfTen(double multiplicand
, int32_t power
);
1043 // We need a custom destructor for the DecNum, which means we need to declare
1044 // the copy/move constructor/assignment quartet.
1046 /** @draft ICU 62 */
1047 Scale(const Scale
& other
);
1049 /** @draft ICU 62 */
1050 Scale
& operator=(const Scale
& other
);
1052 /** @draft ICU 62 */
1053 Scale(Scale
&& src
) U_NOEXCEPT
;
1055 /** @draft ICU 62 */
1056 Scale
& operator=(Scale
&& src
) U_NOEXCEPT
;
1058 /** @draft ICU 62 */
1061 #ifndef U_HIDE_INTERNAL_API
1063 Scale(int32_t magnitude
, impl::DecNum
* arbitraryToAdopt
);
1064 #endif /* U_HIDE_INTERNAL_API */
1068 impl::DecNum
* fArbitrary
;
1071 Scale(UErrorCode error
) : fMagnitude(0), fArbitrary(nullptr), fError(error
) {}
1073 Scale() : fMagnitude(0), fArbitrary(nullptr), fError(U_ZERO_ERROR
) {}
1075 bool isValid() const {
1076 return fMagnitude
!= 0 || fArbitrary
!= nullptr;
1079 UBool
copyErrorTo(UErrorCode
&status
) const {
1080 if (fError
!= U_ZERO_ERROR
) {
1087 void applyTo(impl::DecimalQuantity
& quantity
) const;
1089 void applyReciprocalTo(impl::DecimalQuantity
& quantity
) const;
1091 // To allow MacroProps/MicroProps to initialize empty instances:
1092 friend struct impl::MacroProps
;
1093 friend struct impl::MicroProps
;
1095 // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1096 friend class impl::NumberFormatterImpl
;
1098 // To allow the helper class MultiplierFormatHandler access to private fields:
1099 friend class impl::MultiplierFormatHandler
;
1101 // To allow access to the skeleton generation code:
1102 friend class impl::GeneratorHelpers
;
1104 // To allow access to parsing code:
1105 friend class ::icu::numparse::impl::NumberParserImpl
;
1106 friend class ::icu::numparse::impl::MultiplierParseHandler
;
1111 // Do not enclose entire SymbolsWrapper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1113 class U_I18N_API SymbolsWrapper
: public UMemory
{
1116 SymbolsWrapper() : fType(SYMPTR_NONE
), fPtr
{nullptr} {}
1119 SymbolsWrapper(const SymbolsWrapper
&other
);
1122 SymbolsWrapper
&operator=(const SymbolsWrapper
&other
);
1125 SymbolsWrapper(SymbolsWrapper
&& src
) U_NOEXCEPT
;
1128 SymbolsWrapper
&operator=(SymbolsWrapper
&& src
) U_NOEXCEPT
;
1133 #ifndef U_HIDE_INTERNAL_API
1136 * The provided object is copied, but we do not adopt it.
1139 void setTo(const DecimalFormatSymbols
&dfs
);
1142 * Adopt the provided object.
1145 void setTo(const NumberingSystem
*ns
);
1148 * Whether the object is currently holding a DecimalFormatSymbols.
1151 bool isDecimalFormatSymbols() const;
1154 * Whether the object is currently holding a NumberingSystem.
1157 bool isNumberingSystem() const;
1160 * Get the DecimalFormatSymbols pointer. No ownership change.
1163 const DecimalFormatSymbols
*getDecimalFormatSymbols() const;
1166 * Get the NumberingSystem pointer. No ownership change.
1169 const NumberingSystem
*getNumberingSystem() const;
1171 #endif // U_HIDE_INTERNAL_API
1174 UBool
copyErrorTo(UErrorCode
&status
) const {
1175 if (fType
== SYMPTR_DFS
&& fPtr
.dfs
== nullptr) {
1176 status
= U_MEMORY_ALLOCATION_ERROR
;
1178 } else if (fType
== SYMPTR_NS
&& fPtr
.ns
== nullptr) {
1179 status
= U_MEMORY_ALLOCATION_ERROR
;
1186 enum SymbolsPointerType
{
1187 SYMPTR_NONE
, SYMPTR_DFS
, SYMPTR_NS
1191 const DecimalFormatSymbols
*dfs
;
1192 const NumberingSystem
*ns
;
1195 void doCopyFrom(const SymbolsWrapper
&other
);
1197 void doMoveFrom(SymbolsWrapper
&& src
);
1202 // Do not enclose entire Grouper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1204 class U_I18N_API Grouper
: public UMemory
{
1206 #ifndef U_HIDE_INTERNAL_API
1208 static Grouper
forStrategy(UGroupingStrategy grouping
);
1211 * Resolve the values in Properties to a Grouper object.
1214 static Grouper
forProperties(const DecimalFormatProperties
& properties
);
1216 // Future: static Grouper forProperties(DecimalFormatProperties& properties);
1219 Grouper(int16_t grouping1
, int16_t grouping2
, int16_t minGrouping
, UGroupingStrategy strategy
)
1220 : fGrouping1(grouping1
),
1221 fGrouping2(grouping2
),
1222 fMinGrouping(minGrouping
),
1223 fStrategy(strategy
) {}
1224 #endif // U_HIDE_INTERNAL_API
1227 int16_t getPrimary() const;
1230 int16_t getSecondary() const;
1234 * The grouping sizes, with the following special values:
1236 * <li>-1 = no grouping
1237 * <li>-2 = needs locale data
1238 * <li>-4 = fall back to Western grouping if not in locale
1245 * The minimum grouping size, with the following special values:
1247 * <li>-2 = needs locale data
1248 * <li>-3 = no less than 2
1251 int16_t fMinGrouping
;
1254 * The UGroupingStrategy that was used to create this Grouper, or UNUM_GROUPING_COUNT if this
1255 * was not created from a UGroupingStrategy.
1257 UGroupingStrategy fStrategy
;
1259 Grouper() : fGrouping1(-3) {};
1261 bool isBogus() const {
1262 return fGrouping1
== -3;
1265 /** NON-CONST: mutates the current instance. */
1266 void setLocaleData(const impl::ParsedPatternInfo
&patternInfo
, const Locale
& locale
);
1268 bool groupAtPosition(int32_t position
, const impl::DecimalQuantity
&value
) const;
1270 // To allow MacroProps/MicroProps to initialize empty instances:
1271 friend struct MacroProps
;
1272 friend struct MicroProps
;
1274 // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1275 friend class NumberFormatterImpl
;
1277 // To allow NumberParserImpl to perform setLocaleData():
1278 friend class ::icu::numparse::impl::NumberParserImpl
;
1280 // To allow access to the skeleton generation code:
1281 friend class impl::GeneratorHelpers
;
1284 // Do not enclose entire Padder with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1286 class U_I18N_API Padder
: public UMemory
{
1288 #ifndef U_HIDE_INTERNAL_API
1290 static Padder
none();
1293 static Padder
codePoints(UChar32 cp
, int32_t targetWidth
, UNumberFormatPadPosition position
);
1294 #endif // U_HIDE_INTERNAL_API
1297 static Padder
forProperties(const DecimalFormatProperties
& properties
);
1300 UChar32 fWidth
; // -3 = error; -2 = bogus; -1 = no padding
1304 UNumberFormatPadPosition fPosition
;
1306 UErrorCode errorCode
;
1309 Padder(UChar32 cp
, int32_t width
, UNumberFormatPadPosition position
);
1311 Padder(int32_t width
);
1313 Padder(UErrorCode errorCode
) : fWidth(-3) { // NOLINT
1314 fUnion
.errorCode
= errorCode
;
1317 Padder() : fWidth(-2) {} // NOLINT
1319 bool isBogus() const {
1320 return fWidth
== -2;
1323 UBool
copyErrorTo(UErrorCode
&status
) const {
1325 status
= fUnion
.errorCode
;
1331 bool isValid() const {
1335 int32_t padAndApply(const impl::Modifier
&mod1
, const impl::Modifier
&mod2
,
1336 impl::NumberStringBuilder
&string
, int32_t leftIndex
, int32_t rightIndex
,
1337 UErrorCode
&status
) const;
1339 // To allow MacroProps/MicroProps to initialize empty instances:
1340 friend struct MacroProps
;
1341 friend struct MicroProps
;
1343 // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1344 friend class impl::NumberFormatterImpl
;
1346 // To allow access to the skeleton generation code:
1347 friend class impl::GeneratorHelpers
;
1350 // Do not enclose entire MacroProps with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1352 struct U_I18N_API MacroProps
: public UMemory
{
1357 MeasureUnit unit
; // = NoUnit::base();
1360 MeasureUnit perUnit
; // = NoUnit::base();
1363 Precision precision
; // = Precision(); (bogus)
1366 UNumberFormatRoundingMode roundingMode
= UNUM_ROUND_HALFEVEN
;
1369 Grouper grouper
; // = Grouper(); (bogus)
1372 Padder padder
; // = Padder(); (bogus)
1375 IntegerWidth integerWidth
; // = IntegerWidth(); (bogus)
1378 SymbolsWrapper symbols
;
1380 // UNUM_XYZ_COUNT denotes null (bogus) values.
1383 UNumberUnitWidth unitWidth
= UNUM_UNIT_WIDTH_COUNT
;
1386 UNumberSignDisplay sign
= UNUM_SIGN_COUNT
;
1389 UNumberDecimalSeparatorDisplay decimal
= UNUM_DECIMAL_SEPARATOR_COUNT
;
1392 Scale scale
; // = Scale(); (benign value)
1395 const AffixPatternProvider
* affixProvider
= nullptr; // no ownership
1398 const PluralRules
* rules
= nullptr; // no ownership
1401 const CurrencySymbols
* currencySymbols
= nullptr; // no ownership
1404 int32_t threshold
= DEFAULT_THRESHOLD
;
1409 // NOTE: Uses default copy and move constructors.
1412 * Check all members for errors.
1415 bool copyErrorTo(UErrorCode
&status
) const {
1416 return notation
.copyErrorTo(status
) || precision
.copyErrorTo(status
) ||
1417 padder
.copyErrorTo(status
) || integerWidth
.copyErrorTo(status
) ||
1418 symbols
.copyErrorTo(status
) || scale
.copyErrorTo(status
);
1425 * An abstract base class for specifying settings related to number formatting. This class is implemented by
1426 * {@link UnlocalizedNumberFormatter} and {@link LocalizedNumberFormatter}.
1428 template<typename Derived
>
1429 class U_I18N_API NumberFormatterSettings
{
1432 * Specifies the notation style (simple, scientific, or compact) for rendering numbers.
1435 * <li>Simple notation: "12,300"
1436 * <li>Scientific notation: "1.23E4"
1437 * <li>Compact notation: "12K"
1441 * All notation styles will be properly localized with locale data, and all notation styles are compatible with
1442 * units, rounding precisions, and other number formatter settings.
1445 * Pass this method the return value of a {@link Notation} factory method. For example:
1448 * NumberFormatter::with().notation(Notation::compactShort())
1451 * The default is to use simple notation.
1454 * The notation strategy to use.
1455 * @return The fluent chain.
1459 Derived
notation(const Notation
¬ation
) const &;
1462 * Overload of notation() for use on an rvalue reference.
1465 * The notation strategy to use.
1466 * @return The fluent chain.
1470 Derived
notation(const Notation
¬ation
) &&;
1473 * Specifies the unit (unit of measure, currency, or percent) to associate with rendered numbers.
1476 * <li>Unit of measure: "12.3 meters"
1477 * <li>Currency: "$12.30"
1478 * <li>Percent: "12.3%"
1481 * All units will be properly localized with locale data, and all units are compatible with notation styles,
1482 * rounding precisions, and other number formatter settings.
1484 * Pass this method any instance of {@link MeasureUnit}. For units of measure (which often involve the
1485 * factory methods that return a pointer):
1488 * NumberFormatter::with().adoptUnit(MeasureUnit::createMeter(status))
1494 * NumberFormatter::with().unit(CurrencyUnit(u"USD", status))
1500 * NumberFormatter::with().unit(NoUnit.percent())
1503 * See {@link #perUnit} for information on how to format strings like "5 meters per second".
1505 * The default is to render without units (equivalent to NoUnit.base()).
1508 * The unit to render.
1509 * @return The fluent chain.
1516 Derived
unit(const icu::MeasureUnit
&unit
) const &;
1519 * Overload of unit() for use on an rvalue reference.
1522 * The unit to render.
1523 * @return The fluent chain.
1527 Derived
unit(const icu::MeasureUnit
&unit
) &&;
1530 * Like unit(), but takes ownership of a pointer. Convenient for use with the MeasureFormat factory
1531 * methods, which return pointers that need ownership. Example:
1534 * NumberFormatter::with().adoptUnit(MeasureUnit::createMeter(status))
1538 * The unit to render.
1539 * @return The fluent chain.
1544 Derived
adoptUnit(icu::MeasureUnit
*unit
) const &;
1547 * Overload of adoptUnit() for use on an rvalue reference.
1550 * The unit to render.
1551 * @return The fluent chain.
1555 Derived
adoptUnit(icu::MeasureUnit
*unit
) &&;
1558 * Sets a unit to be used in the denominator. For example, to format "3 m/s", pass METER to the unit and SECOND to
1561 * Pass this method any instance of {@link MeasureUnit}. Since MeasureUnit factory methods return pointers, the
1562 * {@link #adoptPerUnit} version of this method is often more useful.
1564 * The default is not to display any unit in the denominator.
1566 * If a per-unit is specified without a primary unit via {@link #unit}, the behavior is undefined.
1569 * The unit to render in the denominator.
1570 * @return The fluent chain
1574 Derived
perUnit(const icu::MeasureUnit
&perUnit
) const &;
1577 * Overload of perUnit() for use on an rvalue reference.
1580 * The unit to render in the denominator.
1581 * @return The fluent chain.
1585 Derived
perUnit(const icu::MeasureUnit
&perUnit
) &&;
1588 * Like perUnit(), but takes ownership of a pointer. Convenient for use with the MeasureFormat factory
1589 * methods, which return pointers that need ownership. Example:
1592 * NumberFormatter::with()
1593 * .adoptUnit(MeasureUnit::createMeter(status))
1594 * .adoptPerUnit(MeasureUnit::createSecond(status))
1598 * The unit to render in the denominator.
1599 * @return The fluent chain.
1604 Derived
adoptPerUnit(icu::MeasureUnit
*perUnit
) const &;
1607 * Overload of adoptPerUnit() for use on an rvalue reference.
1610 * The unit to render in the denominator.
1611 * @return The fluent chain.
1612 * @see #adoptPerUnit
1615 Derived
adoptPerUnit(icu::MeasureUnit
*perUnit
) &&;
1618 * Specifies the rounding precision to use when formatting numbers.
1621 * <li>Round to 3 decimal places: "3.142"
1622 * <li>Round to 3 significant figures: "3.14"
1623 * <li>Round to the closest nickel: "3.15"
1624 * <li>Do not perform rounding: "3.1415926..."
1628 * Pass this method the return value of one of the factory methods on {@link Precision}. For example:
1631 * NumberFormatter::with().precision(Precision::fixedFraction(2))
1635 * In most cases, the default rounding strategy is to round to 6 fraction places; i.e.,
1636 * <code>Precision.maxFraction(6)</code>. The exceptions are if compact notation is being used, then the compact
1637 * notation rounding strategy is used (see {@link Notation#compactShort} for details), or if the unit is a currency,
1638 * then standard currency rounding is used, which varies from currency to currency (see {@link Precision#currency} for
1642 * The rounding precision to use.
1643 * @return The fluent chain.
1647 Derived
precision(const Precision
& precision
) const &;
1650 * Overload of precision() for use on an rvalue reference.
1653 * The rounding precision to use.
1654 * @return The fluent chain.
1658 Derived
precision(const Precision
& precision
) &&;
1660 #ifndef U_HIDE_DEPRECATED_API
1661 // Compatibility method that will be removed in ICU 64.
1662 // Use precision() instead.
1663 // See http://bugs.icu-project.org/trac/ticket/13746
1664 /** @deprecated ICU 62 */
1665 Derived
rounding(const Rounder
& rounder
) const & {
1666 return precision(rounder
);
1668 #endif /* U_HIDE_DEPRECATED_API */
1671 * Specifies how to determine the direction to round a number when it has more digits than fit in the
1672 * desired precision. When formatting 1.235:
1675 * <li>Ceiling rounding mode with integer precision: "2"
1676 * <li>Half-down rounding mode with 2 fixed fraction digits: "1.23"
1677 * <li>Half-up rounding mode with 2 fixed fraction digits: "1.24"
1680 * The default is HALF_EVEN. For more information on rounding mode, see the ICU userguide here:
1682 * http://userguide.icu-project.org/formatparse/numbers/rounding-modes
1684 * @param roundingMode The rounding mode to use.
1685 * @return The fluent chain.
1688 Derived
roundingMode(UNumberFormatRoundingMode roundingMode
) const &;
1691 * Overload of roundingMode() for use on an rvalue reference.
1693 * @param roundingMode The rounding mode to use.
1694 * @return The fluent chain.
1695 * @see #roundingMode
1698 Derived
roundingMode(UNumberFormatRoundingMode roundingMode
) &&;
1701 * Specifies the grouping strategy to use when formatting numbers.
1704 * <li>Default grouping: "12,300" and "1,230"
1705 * <li>Grouping with at least 2 digits: "12,300" and "1230"
1706 * <li>No grouping: "12300" and "1230"
1710 * The exact grouping widths will be chosen based on the locale.
1713 * Pass this method an element from the {@link UGroupingStrategy} enum. For example:
1716 * NumberFormatter::with().grouping(UNUM_GROUPING_MIN2)
1719 * The default is to perform grouping according to locale data; most locales, but not all locales,
1720 * enable it by default.
1723 * The grouping strategy to use.
1724 * @return The fluent chain.
1727 Derived
grouping(UGroupingStrategy strategy
) const &;
1730 * Overload of grouping() for use on an rvalue reference.
1733 * The grouping strategy to use.
1734 * @return The fluent chain.
1736 * @provisional This API might change or be removed in a future release.
1739 Derived
grouping(UGroupingStrategy strategy
) &&;
1742 * Specifies the minimum and maximum number of digits to render before the decimal mark.
1745 * <li>Zero minimum integer digits: ".08"
1746 * <li>One minimum integer digit: "0.08"
1747 * <li>Two minimum integer digits: "00.08"
1751 * Pass this method the return value of {@link IntegerWidth#zeroFillTo(int)}. For example:
1754 * NumberFormatter::with().integerWidth(IntegerWidth::zeroFillTo(2))
1757 * The default is to have one minimum integer digit.
1760 * The integer width to use.
1761 * @return The fluent chain.
1765 Derived
integerWidth(const IntegerWidth
&style
) const &;
1768 * Overload of integerWidth() for use on an rvalue reference.
1771 * The integer width to use.
1772 * @return The fluent chain.
1773 * @see #integerWidth
1776 Derived
integerWidth(const IntegerWidth
&style
) &&;
1779 * Specifies the symbols (decimal separator, grouping separator, percent sign, numerals, etc.) to use when rendering
1783 * <li><em>en_US</em> symbols: "12,345.67"
1784 * <li><em>fr_FR</em> symbols: "12 345,67"
1785 * <li><em>de_CH</em> symbols: "12’345.67"
1786 * <li><em>my_MY</em> symbols: "၁၂,၃၄၅.၆၇"
1790 * Pass this method an instance of {@link DecimalFormatSymbols}. For example:
1793 * NumberFormatter::with().symbols(DecimalFormatSymbols(Locale("de_CH"), status))
1797 * <strong>Note:</strong> DecimalFormatSymbols automatically chooses the best numbering system based on the locale.
1798 * In the examples above, the first three are using the Latin numbering system, and the fourth is using the Myanmar
1802 * <strong>Note:</strong> The instance of DecimalFormatSymbols will be copied: changes made to the symbols object
1803 * after passing it into the fluent chain will not be seen.
1806 * <strong>Note:</strong> Calling this method will override any previously specified DecimalFormatSymbols
1807 * or NumberingSystem.
1810 * The default is to choose the symbols based on the locale specified in the fluent chain.
1813 * The DecimalFormatSymbols to use.
1814 * @return The fluent chain.
1815 * @see DecimalFormatSymbols
1818 Derived
symbols(const DecimalFormatSymbols
&symbols
) const &;
1821 * Overload of symbols() for use on an rvalue reference.
1824 * The DecimalFormatSymbols to use.
1825 * @return The fluent chain.
1829 Derived
symbols(const DecimalFormatSymbols
&symbols
) &&;
1832 * Specifies that the given numbering system should be used when fetching symbols.
1835 * <li>Latin numbering system: "12,345"
1836 * <li>Myanmar numbering system: "၁၂,၃၄၅"
1837 * <li>Math Sans Bold numbering system: "𝟭𝟮,𝟯𝟰𝟱"
1841 * Pass this method an instance of {@link NumberingSystem}. For example, to force the locale to always use the Latin
1842 * alphabet numbering system (ASCII digits):
1845 * NumberFormatter::with().adoptSymbols(NumberingSystem::createInstanceByName("latn", status))
1849 * <strong>Note:</strong> Calling this method will override any previously specified DecimalFormatSymbols
1850 * or NumberingSystem.
1853 * The default is to choose the best numbering system for the locale.
1856 * This method takes ownership of a pointer in order to work nicely with the NumberingSystem factory methods.
1859 * The NumberingSystem to use.
1860 * @return The fluent chain.
1861 * @see NumberingSystem
1864 Derived
adoptSymbols(NumberingSystem
*symbols
) const &;
1867 * Overload of adoptSymbols() for use on an rvalue reference.
1870 * The NumberingSystem to use.
1871 * @return The fluent chain.
1872 * @see #adoptSymbols
1875 Derived
adoptSymbols(NumberingSystem
*symbols
) &&;
1878 * Sets the width of the unit (measure unit or currency). Most common values:
1881 * <li>Short: "$12.00", "12 m"
1882 * <li>ISO Code: "USD 12.00"
1883 * <li>Full name: "12.00 US dollars", "12 meters"
1887 * Pass an element from the {@link UNumberUnitWidth} enum to this setter. For example:
1890 * NumberFormatter::with().unitWidth(UNumberUnitWidth::UNUM_UNIT_WIDTH_FULL_NAME)
1894 * The default is the SHORT width.
1897 * The width to use when rendering numbers.
1898 * @return The fluent chain
1899 * @see UNumberUnitWidth
1902 Derived
unitWidth(UNumberUnitWidth width
) const &;
1905 * Overload of unitWidth() for use on an rvalue reference.
1908 * The width to use when rendering numbers.
1909 * @return The fluent chain.
1913 Derived
unitWidth(UNumberUnitWidth width
) &&;
1916 * Sets the plus/minus sign display strategy. Most common values:
1919 * <li>Auto: "123", "-123"
1920 * <li>Always: "+123", "-123"
1921 * <li>Accounting: "$123", "($123)"
1925 * Pass an element from the {@link UNumberSignDisplay} enum to this setter. For example:
1928 * NumberFormatter::with().sign(UNumberSignDisplay::UNUM_SIGN_ALWAYS)
1932 * The default is AUTO sign display.
1935 * The sign display strategy to use when rendering numbers.
1936 * @return The fluent chain
1937 * @see UNumberSignDisplay
1940 Derived
sign(UNumberSignDisplay style
) const &;
1943 * Overload of sign() for use on an rvalue reference.
1946 * The sign display strategy to use when rendering numbers.
1947 * @return The fluent chain.
1951 Derived
sign(UNumberSignDisplay style
) &&;
1954 * Sets the decimal separator display strategy. This affects integer numbers with no fraction part. Most common
1963 * Pass an element from the {@link UNumberDecimalSeparatorDisplay} enum to this setter. For example:
1966 * NumberFormatter::with().decimal(UNumberDecimalSeparatorDisplay::UNUM_DECIMAL_SEPARATOR_ALWAYS)
1970 * The default is AUTO decimal separator display.
1973 * The decimal separator display strategy to use when rendering numbers.
1974 * @return The fluent chain
1975 * @see UNumberDecimalSeparatorDisplay
1978 Derived
decimal(UNumberDecimalSeparatorDisplay style
) const &;
1981 * Overload of decimal() for use on an rvalue reference.
1984 * The decimal separator display strategy to use when rendering numbers.
1985 * @return The fluent chain.
1989 Derived
decimal(UNumberDecimalSeparatorDisplay style
) &&;
1992 * Sets a scale (multiplier) to be used to scale the number by an arbitrary amount before formatting.
1993 * Most common values:
1996 * <li>Multiply by 100: useful for percentages.
1997 * <li>Multiply by an arbitrary value: useful for unit conversions.
2001 * Pass an element from a {@link Scale} factory method to this setter. For example:
2004 * NumberFormatter::with().scale(Scale::powerOfTen(2))
2008 * The default is to not apply any multiplier.
2011 * The scale to apply when rendering numbers.
2012 * @return The fluent chain
2015 Derived
scale(const Scale
&scale
) const &;
2018 * Overload of scale() for use on an rvalue reference.
2021 * The scale to apply when rendering numbers.
2022 * @return The fluent chain.
2026 Derived
scale(const Scale
&scale
) &&;
2028 #ifndef U_HIDE_INTERNAL_API
2031 * Set the padding strategy. May be added in the future; see #13338.
2033 * @internal ICU 60: This API is ICU internal only.
2035 Derived
padding(const impl::Padder
&padder
) const &;
2038 Derived
padding(const impl::Padder
&padder
) &&;
2041 * Internal fluent setter to support a custom regulation threshold. A threshold of 1 causes the data structures to
2042 * be built right away. A threshold of 0 prevents the data structures from being built.
2044 * @internal ICU 60: This API is ICU internal only.
2046 Derived
threshold(int32_t threshold
) const &;
2049 Derived
threshold(int32_t threshold
) &&;
2052 * Internal fluent setter to overwrite the entire macros object.
2054 * @internal ICU 60: This API is ICU internal only.
2056 Derived
macros(const impl::MacroProps
& macros
) const &;
2059 Derived
macros(const impl::MacroProps
& macros
) &&;
2062 Derived
macros(impl::MacroProps
&& macros
) const &;
2065 Derived
macros(impl::MacroProps
&& macros
) &&;
2067 #endif /* U_HIDE_INTERNAL_API */
2070 * Creates a skeleton string representation of this number formatter. A skeleton string is a
2071 * locale-agnostic serialized form of a number formatter.
2073 * Not all options are capable of being represented in the skeleton string; for example, a
2074 * DecimalFormatSymbols object. If any such option is encountered, the error code is set to
2075 * U_UNSUPPORTED_ERROR.
2077 * The returned skeleton is in normalized form, such that two number formatters with equivalent
2078 * behavior should produce the same skeleton.
2080 * @return A number skeleton string with behavior corresponding to this number formatter.
2083 UnicodeString
toSkeleton(UErrorCode
& status
) const;
2086 * Sets the UErrorCode if an error occurred in the fluent chain.
2087 * Preserves older error codes in the outErrorCode.
2088 * @return TRUE if U_FAILURE(outErrorCode)
2091 UBool
copyErrorTo(UErrorCode
&outErrorCode
) const {
2092 if (U_FAILURE(outErrorCode
)) {
2093 // Do not overwrite the older error code
2096 fMacros
.copyErrorTo(outErrorCode
);
2097 return U_FAILURE(outErrorCode
);
2100 // NOTE: Uses default copy and move constructors.
2103 impl::MacroProps fMacros
;
2106 // Don't construct me directly! Use (Un)LocalizedNumberFormatter.
2107 NumberFormatterSettings() = default;
2109 friend class LocalizedNumberFormatter
;
2110 friend class UnlocalizedNumberFormatter
;
2114 * A NumberFormatter that does not yet have a locale. In order to format numbers, a locale must be specified.
2116 * @see NumberFormatter
2119 class U_I18N_API UnlocalizedNumberFormatter
2120 : public NumberFormatterSettings
<UnlocalizedNumberFormatter
>, public UMemory
{
2124 * Associate the given locale with the number formatter. The locale is used for picking the appropriate symbols,
2125 * formats, and other data for number display.
2128 * To use the Java default locale, call Locale::getDefault():
2131 * NumberFormatter::with(). ... .locale(Locale::getDefault())
2135 * The locale to use when loading data for number formatting.
2136 * @return The fluent chain.
2139 LocalizedNumberFormatter
locale(const icu::Locale
&locale
) const &;
2142 * Overload of locale() for use on an rvalue reference.
2145 * The locale to use when loading data for number formatting.
2146 * @return The fluent chain.
2150 LocalizedNumberFormatter
locale(const icu::Locale
&locale
) &&;
2153 * Default constructor: puts the formatter into a valid but undefined state.
2157 UnlocalizedNumberFormatter() = default;
2159 // Make default copy constructor call the NumberFormatterSettings copy constructor.
2161 * Returns a copy of this UnlocalizedNumberFormatter.
2164 UnlocalizedNumberFormatter(const UnlocalizedNumberFormatter
&other
);
2168 * The source UnlocalizedNumberFormatter will be left in a valid but undefined state.
2171 UnlocalizedNumberFormatter(UnlocalizedNumberFormatter
&& src
) U_NOEXCEPT
;
2174 * Copy assignment operator.
2177 UnlocalizedNumberFormatter
& operator=(const UnlocalizedNumberFormatter
& other
);
2180 * Move assignment operator:
2181 * The source UnlocalizedNumberFormatter will be left in a valid but undefined state.
2184 UnlocalizedNumberFormatter
& operator=(UnlocalizedNumberFormatter
&& src
) U_NOEXCEPT
;
2187 explicit UnlocalizedNumberFormatter(const NumberFormatterSettings
<UnlocalizedNumberFormatter
>& other
);
2189 explicit UnlocalizedNumberFormatter(
2190 NumberFormatterSettings
<UnlocalizedNumberFormatter
>&& src
) U_NOEXCEPT
;
2192 // To give the fluent setters access to this class's constructor:
2193 friend class NumberFormatterSettings
<UnlocalizedNumberFormatter
>;
2195 // To give NumberFormatter::with() access to this class's constructor:
2196 friend class NumberFormatter
;
2200 * A NumberFormatter that has a locale associated with it; this means .format() methods are available.
2202 * @see NumberFormatter
2205 class U_I18N_API LocalizedNumberFormatter
2206 : public NumberFormatterSettings
<LocalizedNumberFormatter
>, public UMemory
{
2209 * Format the given integer number to a string using the settings specified in the NumberFormatter fluent
2213 * The number to format.
2215 * Set to an ErrorCode if one occurred in the setter chain or during formatting.
2216 * @return A FormattedNumber object; call .toString() to get the string.
2219 FormattedNumber
formatInt(int64_t value
, UErrorCode
&status
) const;
2222 * Format the given float or double to a string using the settings specified in the NumberFormatter fluent setting
2226 * The number to format.
2228 * Set to an ErrorCode if one occurred in the setter chain or during formatting.
2229 * @return A FormattedNumber object; call .toString() to get the string.
2232 FormattedNumber
formatDouble(double value
, UErrorCode
&status
) const;
2235 * Format the given decimal number to a string using the settings
2236 * specified in the NumberFormatter fluent setting chain.
2237 * The syntax of the unformatted number is a "numeric string"
2238 * as defined in the Decimal Arithmetic Specification, available at
2239 * http://speleotrove.com/decimal
2242 * The number to format.
2244 * Set to an ErrorCode if one occurred in the setter chain or during formatting.
2245 * @return A FormattedNumber object; call .toString() to get the string.
2248 FormattedNumber
formatDecimal(StringPiece value
, UErrorCode
& status
) const;
2250 #ifndef U_HIDE_INTERNAL_API
2252 /** Internal method.
2255 FormattedNumber
formatDecimalQuantity(const impl::DecimalQuantity
& dq
, UErrorCode
& status
) const;
2257 /** Internal method for DecimalFormat compatibility.
2260 void getAffixImpl(bool isPrefix
, bool isNegative
, UnicodeString
& result
, UErrorCode
& status
) const;
2263 * Internal method for testing.
2266 const impl::NumberFormatterImpl
* getCompiled() const;
2269 * Internal method for testing.
2272 int32_t getCallCount() const;
2277 * Creates a representation of this LocalizedNumberFormat as an icu::Format, enabling the use
2278 * of this number formatter with APIs that need an object of that type, such as MessageFormat.
2280 * This API is not intended to be used other than for enabling API compatibility. The formatDouble,
2281 * formatInt, and formatDecimal methods should normally be used when formatting numbers, not the Format
2282 * object returned by this method.
2284 * The caller owns the returned object and must delete it when finished.
2286 * @return A Format wrapping this LocalizedNumberFormatter.
2289 Format
* toFormat(UErrorCode
& status
) const;
2292 * Default constructor: puts the formatter into a valid but undefined state.
2296 LocalizedNumberFormatter() = default;
2298 // Make default copy constructor call the NumberFormatterSettings copy constructor.
2300 * Returns a copy of this LocalizedNumberFormatter.
2303 LocalizedNumberFormatter(const LocalizedNumberFormatter
&other
);
2307 * The source LocalizedNumberFormatter will be left in a valid but undefined state.
2310 LocalizedNumberFormatter(LocalizedNumberFormatter
&& src
) U_NOEXCEPT
;
2313 * Copy assignment operator.
2316 LocalizedNumberFormatter
& operator=(const LocalizedNumberFormatter
& other
);
2319 * Move assignment operator:
2320 * The source LocalizedNumberFormatter will be left in a valid but undefined state.
2323 LocalizedNumberFormatter
& operator=(LocalizedNumberFormatter
&& src
) U_NOEXCEPT
;
2325 #ifndef U_HIDE_INTERNAL_API
2328 * This is the core entrypoint to the number formatting pipeline. It performs self-regulation: a static code path
2329 * for the first few calls, and compiling a more efficient data structure if called repeatedly.
2332 * This function is very hot, being called in every call to the number formatting pipeline.
2335 * The results object. This method will mutate it to save the results.
2338 void formatImpl(impl::UFormattedNumberData
*results
, UErrorCode
&status
) const;
2343 * Destruct this LocalizedNumberFormatter, cleaning up any memory it might own.
2346 ~LocalizedNumberFormatter();
2349 // Note: fCompiled can't be a LocalPointer because impl::NumberFormatterImpl is defined in an internal
2350 // header, and LocalPointer needs the full class definition in order to delete the instance.
2351 const impl::NumberFormatterImpl
* fCompiled
{nullptr};
2352 char fUnsafeCallCount
[8] {}; // internally cast to u_atomic_int32_t
2354 explicit LocalizedNumberFormatter(const NumberFormatterSettings
<LocalizedNumberFormatter
>& other
);
2356 explicit LocalizedNumberFormatter(NumberFormatterSettings
<LocalizedNumberFormatter
>&& src
) U_NOEXCEPT
;
2358 LocalizedNumberFormatter(const impl::MacroProps
¯os
, const Locale
&locale
);
2360 LocalizedNumberFormatter(impl::MacroProps
&¯os
, const Locale
&locale
);
2362 void lnfMoveHelper(LocalizedNumberFormatter
&& src
);
2365 * @return true if the compiled formatter is available.
2367 bool computeCompiled(UErrorCode
& status
) const;
2369 // To give the fluent setters access to this class's constructor:
2370 friend class NumberFormatterSettings
<UnlocalizedNumberFormatter
>;
2371 friend class NumberFormatterSettings
<LocalizedNumberFormatter
>;
2373 // To give UnlocalizedNumberFormatter::locale() access to this class's constructor:
2374 friend class UnlocalizedNumberFormatter
;
2378 * The result of a number formatting operation. This class allows the result to be exported in several data types,
2379 * including a UnicodeString and a FieldPositionIterator.
2383 class U_I18N_API FormattedNumber
: public UMemory
{
2385 #ifndef U_HIDE_DEPRECATED_API
2387 * Returns a UnicodeString representation of the formatted number.
2389 * @return a UnicodeString containing the localized number.
2390 * @deprecated ICU 62 Use the version of this method with an error code instead.
2391 * This method was never @stable and will be removed in a future release.
2392 * See http://bugs.icu-project.org/trac/ticket/13746
2394 UnicodeString
toString() const;
2395 #endif /* U_HIDE_DEPRECATED_API */
2398 * Returns a UnicodeString representation of the formatted number.
2401 * Set if an error occurs while formatting the number to the UnicodeString.
2402 * @return a UnicodeString containing the localized number.
2405 UnicodeString
toString(UErrorCode
& status
) const;
2407 #ifndef U_HIDE_DEPRECATED_API
2409 * Appends the formatted number to an Appendable.
2412 * The Appendable to which to append the formatted number string.
2413 * @return The same Appendable, for chaining.
2414 * @deprecated ICU 62 Use the version of this method with an error code instead.
2415 * This method was never @stable and will be removed in a future release.
2416 * See http://bugs.icu-project.org/trac/ticket/13746
2419 Appendable
&appendTo(Appendable
&appendable
);
2420 #endif /* U_HIDE_DEPRECATED_API */
2423 * Appends the formatted number to an Appendable.
2426 * The Appendable to which to append the formatted number string.
2428 * Set if an error occurs while formatting the number to the Appendable.
2429 * @return The same Appendable, for chaining.
2433 Appendable
&appendTo(Appendable
&appendable
, UErrorCode
& status
);
2435 #ifndef U_HIDE_DEPRECATED_API
2437 * Determine the start and end indices of the first occurrence of the given <em>field</em> in the output string.
2438 * This allows you to determine the locations of the integer part, fraction part, and sign.
2441 * If multiple different field attributes are needed, this method can be called repeatedly, or if <em>all</em> field
2442 * attributes are needed, consider using populateFieldPositionIterator().
2445 * If a field occurs multiple times in an output string, such as a grouping separator, this method will only ever
2446 * return the first occurrence. Use populateFieldPositionIterator() to access all occurrences of an attribute.
2448 * @param fieldPosition
2449 * The FieldPosition to populate with the start and end indices of the desired field.
2451 * Set if an error occurs while populating the FieldPosition.
2452 * @deprecated ICU 62 Use {@link #nextFieldPosition} instead. This method will be removed in a future
2453 * release. See http://bugs.icu-project.org/trac/ticket/13746
2454 * @see UNumberFormatFields
2456 void populateFieldPosition(FieldPosition
&fieldPosition
, UErrorCode
&status
);
2457 #endif /* U_HIDE_DEPRECATED_API */
2460 * Determines the start and end indices of the next occurrence of the given <em>field</em> in the
2461 * output string. This allows you to determine the locations of, for example, the integer part,
2462 * fraction part, or symbols.
2464 * If a field occurs just once, calling this method will find that occurrence and return it. If a
2465 * field occurs multiple times, this method may be called repeatedly with the following pattern:
2468 * FieldPosition fpos(UNUM_GROUPING_SEPARATOR_FIELD);
2469 * while (formattedNumber.nextFieldPosition(fpos, status)) {
2470 * // do something with fpos.
2474 * This method is useful if you know which field to query. If you want all available field position
2475 * information, use #getAllFieldPositions().
2477 * @param fieldPosition
2478 * Input+output variable. On input, the "field" property determines which field to look
2479 * up, and the "beginIndex" and "endIndex" properties determine where to begin the search.
2480 * On output, the "beginIndex" is set to the beginning of the first occurrence of the
2481 * field with either begin or end indices after the input indices, "endIndex" is set to
2482 * the end of that occurrence of the field (exclusive index). If a field position is not
2483 * found, the method returns FALSE and the FieldPosition may or may not be changed.
2485 * Set if an error occurs while populating the FieldPosition.
2486 * @return TRUE if a new occurrence of the field was found; FALSE otherwise.
2488 * @see UNumberFormatFields
2490 UBool
nextFieldPosition(FieldPosition
& fieldPosition
, UErrorCode
& status
) const;
2492 #ifndef U_HIDE_DEPRECATED_API
2494 * Export the formatted number to a FieldPositionIterator. This allows you to determine which characters in
2495 * the output string correspond to which <em>fields</em>, such as the integer part, fraction part, and sign.
2498 * If information on only one field is needed, consider using populateFieldPosition() instead.
2501 * The FieldPositionIterator to populate with all of the fields present in the formatted number.
2503 * Set if an error occurs while populating the FieldPositionIterator.
2504 * @deprecated ICU 62 Use {@link #getAllFieldPositions} instead. This method will be removed in a
2505 * future release. See http://bugs.icu-project.org/trac/ticket/13746
2506 * @see UNumberFormatFields
2508 void populateFieldPositionIterator(FieldPositionIterator
&iterator
, UErrorCode
&status
);
2509 #endif /* U_HIDE_DEPRECATED_API */
2512 * Export the formatted number to a FieldPositionIterator. This allows you to determine which characters in
2513 * the output string correspond to which <em>fields</em>, such as the integer part, fraction part, and sign.
2515 * If information on only one field is needed, use #nextFieldPosition() instead.
2518 * The FieldPositionIterator to populate with all of the fields present in the formatted number.
2520 * Set if an error occurs while populating the FieldPositionIterator.
2522 * @see UNumberFormatFields
2524 void getAllFieldPositions(FieldPositionIterator
&iterator
, UErrorCode
&status
) const;
2526 #ifndef U_HIDE_INTERNAL_API
2529 * Gets the raw DecimalQuantity for plural rule selection.
2532 void getDecimalQuantity(impl::DecimalQuantity
& output
, UErrorCode
& status
) const;
2535 * Populates the mutable builder type FieldPositionIteratorHandler.
2538 void getAllFieldPositionsImpl(FieldPositionIteratorHandler
& fpih
, UErrorCode
& status
) const;
2543 * Copying not supported; use move constructor instead.
2545 FormattedNumber(const FormattedNumber
&) = delete;
2548 * Copying not supported; use move assignment instead.
2550 FormattedNumber
& operator=(const FormattedNumber
&) = delete;
2554 * Leaves the source FormattedNumber in an undefined state.
2557 FormattedNumber(FormattedNumber
&& src
) U_NOEXCEPT
;
2561 * Leaves the source FormattedNumber in an undefined state.
2564 FormattedNumber
& operator=(FormattedNumber
&& src
) U_NOEXCEPT
;
2567 * Destruct an instance of FormattedNumber, cleaning up any memory it might own.
2573 // Can't use LocalPointer because UFormattedNumberData is forward-declared
2574 const impl::UFormattedNumberData
*fResults
;
2576 // Error code for the terminal methods
2577 UErrorCode fErrorCode
;
2580 * Internal constructor from data type. Adopts the data pointer.
2583 explicit FormattedNumber(impl::UFormattedNumberData
*results
)
2584 : fResults(results
), fErrorCode(U_ZERO_ERROR
) {};
2586 explicit FormattedNumber(UErrorCode errorCode
)
2587 : fResults(nullptr), fErrorCode(errorCode
) {};
2589 // To give LocalizedNumberFormatter format methods access to this class's constructor:
2590 friend class LocalizedNumberFormatter
;
2594 * See the main description in numberformatter.h for documentation and examples.
2598 class U_I18N_API NumberFormatter final
{
2601 * Call this method at the beginning of a NumberFormatter fluent chain in which the locale is not currently known at
2604 * @return An {@link UnlocalizedNumberFormatter}, to be used for chaining.
2607 static UnlocalizedNumberFormatter
with();
2610 * Call this method at the beginning of a NumberFormatter fluent chain in which the locale is known at the call
2614 * The locale from which to load formats and symbols for number formatting.
2615 * @return A {@link LocalizedNumberFormatter}, to be used for chaining.
2618 static LocalizedNumberFormatter
withLocale(const Locale
&locale
);
2621 * Call this method at the beginning of a NumberFormatter fluent chain to create an instance based
2622 * on a given number skeleton string.
2625 * The skeleton string off of which to base this NumberFormatter.
2627 * Set to U_NUMBER_SKELETON_SYNTAX_ERROR if the skeleton was invalid.
2628 * @return An UnlocalizedNumberFormatter, to be used for chaining.
2631 static UnlocalizedNumberFormatter
forSkeleton(const UnicodeString
& skeleton
, UErrorCode
& status
);
2634 * Use factory methods instead of the constructor to create a NumberFormatter.
2636 NumberFormatter() = delete;
2639 } // namespace number
2642 #endif // U_HIDE_DRAFT_API
2644 #endif // __NUMBERFORMATTER_H__
2646 #endif /* #if !UCONFIG_NO_FORMATTING */