ICU 76.1: i18n/unicode/numberrangeformatter.h File Reference

ICU 76.1 76.1

Data Structures | Namespaces
numberrangeformatter.h File Reference

C++ API: Library for localized formatting of number, currency, and unit ranges. More...

`#include "unicode/utypes.h"`
`#include <atomic>`
`#include "unicode/appendable.h"`
`#include "unicode/fieldpos.h"`
`#include "unicode/formattedvalue.h"`
`#include "unicode/fpositer.h"`
`#include "unicode/numberformatter.h"`
`#include "unicode/unumberrangeformatter.h"`

Go to the source code of this file.

## Data Structures
struct | icu::number::impl::RangeMacroProps
class | icu::number::NumberRangeFormatterSettings< Derived >
| An abstract base class for specifying settings related to number formatting. More...
class | icu::number::UnlocalizedNumberRangeFormatter
| A NumberRangeFormatter that does not yet have a locale. More...
class | icu::number::LocalizedNumberRangeFormatter
| A NumberRangeFormatter that has a locale associated with it; this means .formatRange() methods are available. More...
class | icu::number::FormattedNumberRange
| The result of a number range formatting operation. More...
class | icu::number::NumberRangeFormatter
| See the main description in numberrangeformatter.h for documentation and examples. More...

## Namespaces
namespace | icu
| File coll.h.

## Detailed Description

C++ API: Library for localized formatting of number, currency, and unit ranges.

The main entrypoint to the formatting of ranges of numbers, including currencies and other units of measurement.

Usage example:

    NumberRangeFormatter::with()
        .identityFallback(UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE)
        .numberFormatterFirst(NumberFormatter::with().adoptUnit(MeasureUnit::createMeter()))
        .numberFormatterSecond(NumberFormatter::with().adoptUnit(MeasureUnit::createKilometer()))
        .locale("en-GB")
        .formatFormattableRange(750, 1.2, status)
        .toString(status);
    // => "750 m - 1.2 km"

<p<blockquote>‍ Like NumberFormatter, NumberRangeFormatter instances (i.e., LocalizedNumberRangeFormatter and UnlocalizedNumberRangeFormatter) are immutable and thread-safe. This API is based on the fluent design pattern popularized by libraries such as Google's Guava.

Author
  Shane Carr

Definition in file numberrangeformatter.h.