ICU 74.1 74.1

Public Member Functions | Friends
icu::number::NumberFormatterSettings< Derived > Class Template Reference

An abstract base class for specifying settings related to number formatting. More...

`#include <numberformatter.h>`

## Public Member Functions
Derived | notation (const Notation &notation) const &
| Specifies the notation style (simple, scientific, or compact) for rendering numbers. More...
Derived | notation (const Notation &notation) &&
| Overload of notation() for use on an rvalue reference. More...
Derived | unit (const icu::MeasureUnit &unit) const &
| Specifies the unit (unit of measure, currency, or percent) to associate with rendered numbers. More...
Derived | unit (const icu::MeasureUnit &unit) &&
| Overload of unit() for use on an rvalue reference. More...
Derived | adoptUnit (icu::MeasureUnit *unit) const &
| Like unit(), but takes ownership of a pointer. More...
Derived | adoptUnit (icu::MeasureUnit *unit) &&
| Overload of adoptUnit() for use on an rvalue reference. More...
Derived | perUnit (const icu::MeasureUnit &perUnit) const &
| Sets a unit to be used in the denominator. More...
Derived | perUnit (const icu::MeasureUnit &perUnit) &&
| Overload of perUnit() for use on an rvalue reference. More...
Derived | adoptPerUnit (icu::MeasureUnit *perUnit) const &
| Like perUnit(), but takes ownership of a pointer. More...
Derived | adoptPerUnit (icu::MeasureUnit *perUnit) &&
| Overload of adoptPerUnit() for use on an rvalue reference. More...
Derived | precision (const Precision &precision) const &
| Specifies the rounding precision to use when formatting numbers. More...
Derived | precision (const Precision &precision) &&
| Overload of precision() for use on an rvalue reference. More...
Derived | roundingMode (UNumberFormatRoundingMode roundingMode) const &
| Specifies how to determine the direction to round a number when it has more digits than fit in the desired precision. More...
Derived | roundingMode (UNumberFormatRoundingMode roundingMode) &&
| Overload of roundingMode() for use on an rvalue reference. More...
Derived | grouping (UNumberGroupingStrategy strategy) const &
| Specifies the grouping strategy to use when formatting numbers. More...
Derived | grouping (UNumberGroupingStrategy strategy) &&
| Overload of grouping() for use on an rvalue reference. More...
Derived | integerWidth (const IntegerWidth &style) const &
| Specifies the minimum and maximum number of digits to render before the decimal mark. More...
Derived | integerWidth (const IntegerWidth &style) &&
| Overload of integerWidth() for use on an rvalue reference. More...
Derived | symbols (const DecimalFormatSymbols &symbols) const &
| Specifies the symbols (decimal separator, grouping separator, percent sign, numerals, etc.) to use when rendering numbers. More...
Derived | symbols (const DecimalFormatSymbols &symbols) &&
| Overload of symbols() for use on an rvalue reference. More...
Derived | adoptSymbols (NumberingSystem *symbols) const &
| Specifies that the given numbering system should be used when fetching symbols. More...
Derived | adoptSymbols (NumberingSystem *symbols) &&
| Overload of adoptSymbols() for use on an rvalue reference. More...
Derived | unitWidth (UNumberUnitWidth width) const &
| Sets the width of the unit (measure unit or currency). More...
Derived | unitWidth (UNumberUnitWidth width) &&
| Overload of unitWidth() for use on an rvalue reference. More...
Derived | sign (UNumberSignDisplay style) const &
| Sets the plus/minus sign display strategy. More...
Derived | sign (UNumberSignDisplay style) &&
| Overload of sign() for use on an rvalue reference. More...
Derived | decimal (UNumberDecimalSeparatorDisplay style) const &
| Sets the decimal separator display strategy. More...
Derived | decimal (UNumberDecimalSeparatorDisplay style) &&
| Overload of decimal() for use on an rvalue reference. More...
Derived | scale (const Scale &scale) const &
| Sets a scale (multiplier) to be used to scale the number by an arbitrary amount before formatting. More...
Derived | scale (const Scale &scale) &&
| Overload of scale() for use on an rvalue reference. More...
Derived | usage (StringPiece usage) const &
| Specifies the usage for which numbers will be formatted ("person-height", "road", "rainfall", etc.) More...
Derived | usage (StringPiece usage) &&
| Overload of usage() for use on an rvalue reference. More...
Derived | displayOptions (const DisplayOptions &displayOptions) const &
| Specifies the DisplayOptions. More...
Derived | displayOptions (const DisplayOptions &displayOptions) &&
| Overload of displayOptions() for use on an rvalue reference. More...
Derived | unitDisplayCase (StringPiece unitDisplayCase) const &
| NOTE: Use `displayOptions` instead. More...
Derived | unitDisplayCase (StringPiece unitDisplayCase) &&
| NOTE: Use `displayOptions` instead. More...
Derived | padding (const impl::Padder &padder) const &
| Set the padding strategy. More...
Derived | padding (const impl::Padder &padder) &&
Derived | threshold (int32_t threshold) const &
| Internal fluent setter to support a custom regulation threshold. More...
Derived | threshold (int32_t threshold) &&
Derived | macros (const impl::MacroProps &macros) const &
| Internal fluent setter to overwrite the entire macros object. More...
Derived | macros (const impl::MacroProps &macros) &&
Derived | macros (impl::MacroProps &&macros) const &
Derived | macros (impl::MacroProps &&macros) &&
UnicodeString | toSkeleton (UErrorCode &status) const
| Creates a skeleton string representation of this number formatter. More...
LocalPointer< Derived > | clone () const &
| Returns the current (Un)LocalizedNumberFormatter as a LocalPointer wrapping a heap-allocated copy of the current object. More...
LocalPointer< Derived > | clone () &&
| Overload of clone for use on an rvalue reference. More...
UBool | copyErrorTo (UErrorCode &outErrorCode) const
| Sets the UErrorCode if an error occurred in the fluent chain. More...

## Friends
class | LocalizedNumberFormatter
class | UnlocalizedNumberFormatter
class | impl::NumberRangeFormatterImpl
void | impl::touchRangeLocales (impl::RangeMacroProps &macros)

## Detailed Description

### template<typename Derived>
class icu::number::NumberFormatterSettings< Derived >

An abstract base class for specifying settings related to number formatting.

This class is implemented by UnlocalizedNumberFormatter and LocalizedNumberFormatter. This class is not intended for public subclassing.

Definition at line 1619 of file numberformatter.h.

## Member Function Documentation

## ◆ adoptPerUnit() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::adoptPerUnit | ( | icu::MeasureUnit * | perUnit | ) | &&

Overload of adoptPerUnit() for use on an rvalue reference.

Parameters

  perUnit | The unit to render in the denominator.

Returns
  The fluent chain.

See also
  adoptPerUnit

Stable:
  ICU 62

## ◆ adoptPerUnit() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::adoptPerUnit | ( | icu::MeasureUnit * | perUnit | ) | const &

Like perUnit(), but takes ownership of a pointer.

Convenient for use with the MeasureFormat factory methods that return pointers that need ownership.

Note: consider using the MeasureFormat factory methods that return by value.

Parameters

  perUnit | The unit to render in the denominator.

Returns
  The fluent chain.

See also
  perUnit
  MeasureUnit

Stable:
  ICU 61

## ◆ adoptSymbols() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::adoptSymbols | ( | NumberingSystem * | symbols | ) | &&

Overload of adoptSymbols() for use on an rvalue reference.

Parameters

  symbols | The NumberingSystem to use.

Returns
  The fluent chain.

See also
  adoptSymbols

Stable:
  ICU 62

## ◆ adoptSymbols() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::adoptSymbols | ( | NumberingSystem * | symbols | ) | const &

Specifies that the given numbering system should be used when fetching symbols.

- Latin numbering system: "12,345"
- Myanmar numbering system: "၁၂,၃၄၅"
- Math Sans Bold numbering system: "𝟭𝟮,𝟯𝟰𝟱"

Pass this method an instance of NumberingSystem. For example, to force the locale to always use the Latin alphabet numbering system (ASCII digits):

    NumberFormatter::with().adoptSymbols(NumberingSystem::createInstanceByName("latn", status))

Note: Calling this method will override any previously specified DecimalFormatSymbols or NumberingSystem.

The default is to choose the best numbering system for the locale.

This method takes ownership of a pointer in order to work nicely with the NumberingSystem factory methods.

Parameters

  symbols | The NumberingSystem to use.

Returns
  The fluent chain.

See also
  NumberingSystem

Stable:
  ICU 60

## ◆ adoptUnit() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::adoptUnit | ( | icu::MeasureUnit * | unit | ) | &&

Overload of adoptUnit() for use on an rvalue reference.

Parameters

  unit | The unit to render.

Returns
  The fluent chain.

See also
  adoptUnit

Stable:
  ICU 62

## ◆ adoptUnit() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::adoptUnit | ( | icu::MeasureUnit * | unit | ) | const &

Like unit(), but takes ownership of a pointer.

Convenient for use with the MeasureFormat factory methods that return pointers that need ownership.

Note: consider using the MeasureFormat factory methods that return by value.

Parameters

  unit | The unit to render.

Returns
  The fluent chain.

See also
  unit
  MeasureUnit

Stable:
  ICU 60

## ◆ clone() [1/2]

template<typename Derived >

LocalPointer<Derived> icu::number::NumberFormatterSettings< Derived >::clone | ( |  | ) | &&

Overload of clone for use on an rvalue reference.

Returns
  A wrapped (Un)LocalizedNumberFormatter pointer, or a wrapped nullptr on failure.

Stable:
  ICU 64

## ◆ clone() [2/2]

template<typename Derived >

LocalPointer<Derived> icu::number::NumberFormatterSettings< Derived >::clone | ( |  | ) | const &

Returns the current (Un)LocalizedNumberFormatter as a LocalPointer wrapping a heap-allocated copy of the current object.

This is equivalent to new-ing the move constructor with a value object as the argument.

Returns
  A wrapped (Un)LocalizedNumberFormatter pointer, or a wrapped nullptr on failure.

Stable:
  ICU 64

## ◆ copyErrorTo()

template<typename Derived >

UBool icu::number::NumberFormatterSettings< Derived >::copyErrorTo | ( | UErrorCode & | outErrorCode | ) | const
| inline

Sets the UErrorCode if an error occurred in the fluent chain.

Preserves older error codes in the outErrorCode.

Returns
  true if U_FAILURE(outErrorCode)

Stable:
  ICU 60

Definition at line 2395 of file numberformatter.h.

References U_FAILURE.

Referenced by icu::number::impl::RangeMacroProps::copyErrorTo().

## ◆ decimal() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::decimal | ( | UNumberDecimalSeparatorDisplay | style | ) | &&

Overload of decimal() for use on an rvalue reference.

Parameters

  style | The decimal separator display strategy to use when rendering numbers.

Returns
  The fluent chain.

See also
  decimal

Stable:
  ICU 62

## ◆ decimal() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::decimal | ( | UNumberDecimalSeparatorDisplay | style | ) | const &

Sets the decimal separator display strategy.

This affects integer numbers with no fraction part. Most common values:

- Auto: "1"
- Always: "1."

Pass an element from the UNumberDecimalSeparatorDisplay enum to this setter. For example:

    NumberFormatter::with().decimal(UNumberDecimalSeparatorDisplay::UNUM_DECIMAL_SEPARATOR_ALWAYS)

The default is AUTO decimal separator display.

Parameters

  style | The decimal separator display strategy to use when rendering numbers.

Returns
  The fluent chain

See also
  UNumberDecimalSeparatorDisplay

Stable:
  ICU 60

## ◆ displayOptions() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::displayOptions | ( | const DisplayOptions & | displayOptions | ) | &&

Overload of displayOptions() for use on an rvalue reference.

Parameters

  displayOptions |

Returns
  The fluent chain.

Stable:
  ICU 72

## ◆ displayOptions() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::displayOptions | ( | const DisplayOptions & | displayOptions | ) | const &

Specifies the DisplayOptions.

For example, UDisplayOptionsGrammaticalCase specifies the desired case for a unit formatter's output (e.g. accusative, dative, genitive).

Parameters

  displayOptions |

Returns
  The fluent chain.

Stable:
  ICU 72

## ◆ grouping() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::grouping | ( | UNumberGroupingStrategy | strategy | ) | &&

Overload of grouping() for use on an rvalue reference.

Parameters

  strategy | The grouping strategy to use.

Returns
  The fluent chain.

See also
  grouping

Stable:
  ICU 62

## ◆ grouping() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::grouping | ( | UNumberGroupingStrategy | strategy | ) | const &

Specifies the grouping strategy to use when formatting numbers.

- Default grouping: "12,300" and "1,230"
- Grouping with at least 2 digits: "12,300" and "1230"
- No grouping: "12300" and "1230"

The exact grouping widths will be chosen based on the locale.

Pass this method an element from the UNumberGroupingStrategy enum. For example:

    NumberFormatter::with().grouping(UNUM_GROUPING_MIN2)

The default is to perform grouping according to locale data; most locales, but not all locales, enable it by default.

Parameters

  strategy | The grouping strategy to use.

Returns
  The fluent chain.

Stable:
  ICU 61

## ◆ integerWidth() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::integerWidth | ( | const IntegerWidth & | style | ) | &&

Overload of integerWidth() for use on an rvalue reference.

Parameters

  style | The integer width to use.

Returns
  The fluent chain.

See also
  integerWidth

Stable:
  ICU 62

## ◆ integerWidth() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::integerWidth | ( | const IntegerWidth & | style | ) | const &

Specifies the minimum and maximum number of digits to render before the decimal mark.

- Zero minimum integer digits: ".08"
- One minimum integer digit: "0.08"
- Two minimum integer digits: "00.08"

Pass this method the return value of IntegerWidth#zeroFillTo. For example:

    NumberFormatter::with().integerWidth(IntegerWidth::zeroFillTo(2))

The default is to have one minimum integer digit.

Parameters

  style | The integer width to use.

Returns
  The fluent chain.

See also
  IntegerWidth

Stable:
  ICU 60

## ◆ macros() [1/4]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::macros | ( | const impl::MacroProps & | macros | ) | &&

Internal:
  Do not use.

This API is for internal use only.

## ◆ macros() [2/4]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::macros | ( | const impl::MacroProps & | macros | ) | const &

Internal fluent setter to overwrite the entire macros object.

Internal:
  Do not use. This API is for internal use only. ICU 60: This API is ICU internal only.

## ◆ macros() [3/4]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::macros | ( | impl::MacroProps && | macros | ) | &&

Internal:
  Do not use.

This API is for internal use only.

## ◆ macros() [4/4]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::macros | ( | impl::MacroProps && | macros | ) | const &

Internal:
  Do not use.

This API is for internal use only.

## ◆ notation() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::notation | ( | const Notation & | notation | ) | &&

Overload of notation() for use on an rvalue reference.

Parameters

  notation | The notation strategy to use.

Returns
  The fluent chain.

See also
  notation

Stable:
  ICU 62

## ◆ notation() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::notation | ( | const Notation & | notation | ) | const &

Specifies the notation style (simple, scientific, or compact) for rendering numbers.

- Simple notation: "12,300"
- Scientific notation: "1.23E4"
- Compact notation: "12K"

All notation styles will be properly localized with locale data, and all notation styles are compatible with units, rounding precisions, and other number formatter settings.

Pass this method the return value of a Notation factory method. For example:

    NumberFormatter::with().notation(Notation::compactShort())

The default is to use simple notation.

Parameters

  notation | The notation strategy to use.

Returns
  The fluent chain.

See also
  Notation

Stable:
  ICU 60

## ◆ padding() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::padding | ( | const impl::Padder & | padder | ) | &&

Internal:
  Do not use.

This API is for internal use only.

## ◆ padding() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::padding | ( | const impl::Padder & | padder | ) | const &

Set the padding strategy.

May be added in the future; see #13338.

Internal:
  Do not use. This API is for internal use only. ICU 60: This API is ICU internal only.

## ◆ perUnit() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::perUnit | ( | const icu::MeasureUnit & | perUnit | ) | &&

Overload of perUnit() for use on an rvalue reference.

Parameters

  perUnit | The unit to render in the denominator.

Returns
  The fluent chain.

See also
  perUnit

Stable:
  ICU 62

## ◆ perUnit() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::perUnit | ( | const icu::MeasureUnit & | perUnit | ) | const &

Sets a unit to be used in the denominator.

For example, to format "3 m/s", pass METER to the unit and SECOND to the perUnit.

Pass this method any instance of MeasureUnit. Example:

    NumberFormatter::with()
         .unit(MeasureUnit::getMeter())
         .perUnit(MeasureUnit::getSecond())

The default is not to display any unit in the denominator.

If a per-unit is specified without a primary unit via unit, the behavior is undefined.

Parameters

  perUnit | The unit to render in the denominator.

Returns
  The fluent chain

See also
  unit

Stable:
  ICU 61

## ◆ precision() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::precision | ( | const Precision & | precision | ) | &&

Overload of precision() for use on an rvalue reference.

Parameters

  precision | The rounding precision to use.

Returns
  The fluent chain.

See also
  precision

Stable:
  ICU 62

## ◆ precision() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::precision | ( | const Precision & | precision | ) | const &

Specifies the rounding precision to use when formatting numbers.

- Round to 3 decimal places: "3.142"
- Round to 3 significant figures: "3.14"
- Round to the closest nickel: "3.15"
- Do not perform rounding: "3.1415926..."

Pass this method the return value of one of the factory methods on Precision. For example:

    NumberFormatter::with().precision(Precision::fixedFraction(2))

In most cases, the default rounding strategy is to round to 6 fraction places; i.e., `Precision.maxFraction(6)`. The exceptions are if compact notation is being used, then the compact notation rounding strategy is used (see Notation#compactShort for details), or if the unit is a currency, then standard currency rounding is used, which varies from currency to currency (see Precision#currency for details).

Parameters

  precision | The rounding precision to use.

Returns
  The fluent chain.

See also
  Precision

Stable:
  ICU 62

## ◆ roundingMode() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::roundingMode | ( | UNumberFormatRoundingMode | roundingMode | ) | &&

Overload of roundingMode() for use on an rvalue reference.

Parameters

  roundingMode | The rounding mode to use.

Returns
  The fluent chain.

See also
  roundingMode

Stable:
  ICU 62

## ◆ roundingMode() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::roundingMode | ( | UNumberFormatRoundingMode | roundingMode | ) | const &

Specifies how to determine the direction to round a number when it has more digits than fit in the desired precision.

When formatting 1.235:

- Ceiling rounding mode with integer precision: "2"
- Half-down rounding mode with 2 fixed fraction digits: "1.23"
- Half-up rounding mode with 2 fixed fraction digits: "1.24"

The default is HALF_EVEN. For more information on rounding mode, see the ICU userguide here:

https://unicode-org.github.io/icu/userguide/format_parse/numbers/rounding-modes

Parameters

  roundingMode | The rounding mode to use.

Returns
  The fluent chain.

Stable:
  ICU 62

## ◆ scale() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::scale | ( | const Scale & | scale | ) | &&

Overload of scale() for use on an rvalue reference.

Parameters

  scale | The scale to apply when rendering numbers.

Returns
  The fluent chain.

See also
  scale

Stable:
  ICU 62

## ◆ scale() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::scale | ( | const Scale & | scale | ) | const &

Sets a scale (multiplier) to be used to scale the number by an arbitrary amount before formatting.

Most common values:

- Multiply by 100: useful for percentages.
- Multiply by an arbitrary value: useful for unit conversions.

Pass an element from a Scale factory method to this setter. For example:

    NumberFormatter::with().scale(Scale::powerOfTen(2))

The default is to not apply any multiplier.

Parameters

  scale | The scale to apply when rendering numbers.

Returns
  The fluent chain

Stable:
  ICU 62

## ◆ sign() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::sign | ( | UNumberSignDisplay | style | ) | &&

Overload of sign() for use on an rvalue reference.

Parameters

  style | The sign display strategy to use when rendering numbers.

Returns
  The fluent chain.

See also
  sign

Stable:
  ICU 62

## ◆ sign() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::sign | ( | UNumberSignDisplay | style | ) | const &

Sets the plus/minus sign display strategy.

Most common values:

- Auto: "123", "-123"
- Always: "+123", "-123"
- Accounting: "$123", "($123)"

Pass an element from the UNumberSignDisplay enum to this setter. For example:

    NumberFormatter::with().sign(UNumberSignDisplay::UNUM_SIGN_ALWAYS)

The default is AUTO sign display.

Parameters

  style | The sign display strategy to use when rendering numbers.

Returns
  The fluent chain

See also
  UNumberSignDisplay

Stable:
  ICU 60

## ◆ symbols() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::symbols | ( | const DecimalFormatSymbols & | symbols | ) | &&

Overload of symbols() for use on an rvalue reference.

Parameters

  symbols | The DecimalFormatSymbols to use.

Returns
  The fluent chain.

See also
  symbols

Stable:
  ICU 62

## ◆ symbols() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::symbols | ( | const DecimalFormatSymbols & | symbols | ) | const &

Specifies the symbols (decimal separator, grouping separator, percent sign, numerals, etc.) to use when rendering numbers.

- en_US symbols: "12,345.67"
- fr_FR symbols: "12&nbsp;345,67"
- de_CH symbols: "12’345.67"
- my_MY symbols: "၁၂,၃၄၅.၆၇"

Pass this method an instance of DecimalFormatSymbols. For example:

    NumberFormatter::with().symbols(DecimalFormatSymbols(Locale("de_CH"), status))

Note: DecimalFormatSymbols automatically chooses the best numbering system based on the locale. In the examples above, the first three are using the Latin numbering system, and the fourth is using the Myanmar numbering system.

Note: The instance of DecimalFormatSymbols will be copied: changes made to the symbols object after passing it into the fluent chain will not be seen.

Note: Calling this method will override any previously specified DecimalFormatSymbols or NumberingSystem.

The default is to choose the symbols based on the locale specified in the fluent chain.

Parameters

  symbols | The DecimalFormatSymbols to use.

Returns
  The fluent chain.

See also
  DecimalFormatSymbols

Stable:
  ICU 60

## ◆ threshold() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::threshold | ( | int32_t | threshold | ) | &&

Internal:
  Do not use.

This API is for internal use only.

## ◆ threshold() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::threshold | ( | int32_t | threshold | ) | const &

Internal fluent setter to support a custom regulation threshold.

A threshold of 1 causes the data structures to be built right away. A threshold of 0 prevents the data structures from being built.

Internal:
  Do not use. This API is for internal use only. ICU 60: This API is ICU internal only.

## ◆ toSkeleton()

template<typename Derived >

UnicodeString icu::number::NumberFormatterSettings< Derived >::toSkeleton | ( | UErrorCode & | status | ) | const

Creates a skeleton string representation of this number formatter.

A skeleton string is a locale-agnostic serialized form of a number formatter.

Not all options are capable of being represented in the skeleton string; for example, a DecimalFormatSymbols object. If any such option is encountered, the error code is set to U_UNSUPPORTED_ERROR.

The returned skeleton is in normalized form, such that two number formatters with equivalent behavior should produce the same skeleton.

For more information on number skeleton strings, see: https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html

Returns
  A number skeleton string with behavior corresponding to this number formatter.

Stable:
  ICU 62

## ◆ unit() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::unit | ( | const icu::MeasureUnit & | unit | ) | &&

Overload of unit() for use on an rvalue reference.

Parameters

  unit | The unit to render.

Returns
  The fluent chain.

See also
  unit

Stable:
  ICU 62

## ◆ unit() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::unit | ( | const icu::MeasureUnit & | unit | ) | const &

Specifies the unit (unit of measure, currency, or percent) to associate with rendered numbers.

- Unit of measure: "12.3 meters"
- Currency: "$12.30"
- Percent: "12.3%"

All units will be properly localized with locale data, and all units are compatible with notation styles, rounding precisions, and other number formatter settings.

Note
  If the usage() is set, the output unit will be changed to produce localised units, according to usage, locale and unit. See FormattedNumber::getOutputUnit().

Pass this method any instance of MeasureUnit. For units of measure:

    NumberFormatter::with().unit(MeasureUnit::getMeter())
    NumberFormatter::with().unit(MeasureUnit::forIdentifier("foot-per-second", status))

Currency:

    NumberFormatter::with().unit(CurrencyUnit(u"USD", status))

Percent:

    NumberFormatter::with().unit(NoUnit.percent())

See perUnit for information on how to format strings like "5 meters per second".

The default is to render without units (equivalent to NoUnit.base()).

Parameters

  unit | The unit to render.

Returns
  The fluent chain.

See also
  MeasureUnit
  Currency
  NoUnit
  perUnit

Stable:
  ICU 60

## ◆ unitDisplayCase() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::unitDisplayCase | ( | StringPiece | unitDisplayCase | ) | &&

NOTE: Use `displayOptions` instead.

This method was part of an internal technology preview in ICU 69, but will be removed in ICU 73, in favor of `displayOptions`

Overload of unitDisplayCase() for use on an rvalue reference.

Internal:
  Do not use. This API is for internal use only.

## ◆ unitDisplayCase() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::unitDisplayCase | ( | StringPiece | unitDisplayCase | ) | const &

NOTE: Use `displayOptions` instead.

This method was part of an internal technology preview in ICU 69, but will be removed in ICU 73, in favor of `displayOptions`

Specifies the desired case for a unit formatter's output (e.g. accusative, dative, genitive).

Internal:
  Do not use. This API is for internal use only.

## ◆ unitWidth() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::unitWidth | ( | UNumberUnitWidth | width | ) | &&

Overload of unitWidth() for use on an rvalue reference.

Parameters

  width | The width to use when rendering numbers.

Returns
  The fluent chain.

See also
  unitWidth

Stable:
  ICU 62

## ◆ unitWidth() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::unitWidth | ( | UNumberUnitWidth | width | ) | const &

Sets the width of the unit (measure unit or currency).

Most common values:

- Short: "$12.00", "12 m"
- ISO Code: "USD 12.00"
- Full name: "12.00 US dollars", "12 meters"

Pass an element from the UNumberUnitWidth enum to this setter. For example:

    NumberFormatter::with().unitWidth(UNumberUnitWidth::UNUM_UNIT_WIDTH_FULL_NAME)

The default is the SHORT width.

Parameters

  width | The width to use when rendering numbers.

Returns
  The fluent chain

See also
  UNumberUnitWidth

Stable:
  ICU 60

## ◆ usage() [1/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::usage | ( | StringPiece | usage | ) | &&

Overload of usage() for use on an rvalue reference.

Parameters

  usage | The unit `usage`.

Returns
  The fluent chain.

Stable:
  ICU 68

## ◆ usage() [2/2]

template<typename Derived >

Derived icu::number::NumberFormatterSettings< Derived >::usage | ( | StringPiece | usage | ) | const &

Specifies the usage for which numbers will be formatted ("person-height", "road", "rainfall", etc.)

When a `usage` is specified, the output unit will change depending on the `Locale` and the unit quantity. For example, formatting length measurements specified in meters:

`NumberFormatter::with().usage("person").unit(MeasureUnit::getMeter()).locale("en-US")`

- When formatting 0.25, the output will be "10 inches".
- When formatting 1.50, the output will be "4 feet and 11 inches".

The input unit specified via unit() determines the type of measurement being formatted (e.g. "length" when the unit is "foot"). The usage requested will be looked for only within this category of measurement units.

The output unit can be found via FormattedNumber::getOutputUnit().

If the usage has multiple parts (e.g. "land-agriculture-grain") and does not match a known usage preference, the last part will be dropped repeatedly until a match is found (e.g. trying "land-agriculture", then "land"). If a match is still not found, usage will fall back to "default".

Setting usage to an empty string clears the usage (disables usage-based localized formatting).

Setting a usage string but not a correct input unit will result in an U_ILLEGAL_ARGUMENT_ERROR.

When using usage, specifying rounding or precision is unnecessary. Specifying a precision in some manner will override the default formatting.

Parameters

  usage | A `usage` parameter from the units resource. See the unitPreferenceData in source/data/misc/units.txt, generated from `unitPreferenceData` in CLDR's supplemental/units.xml.

Returns
  The fluent chain.

Stable:
  ICU 68

The documentation for this class was generated from the following file:

- i18n/unicode/numberformatter.h