format currency range

Description

UPDATE: This API is available in ICU 63.

C++:
http://icu-project.org/apiref/icu4c/numberrangeformatter_8h.html

Java:
http://icu-project.org/apiref/icu4c/classicu_1_1number_1_1NumberRangeFormatter.html

Split from

We've gotten a request for formatting currencies with ranges, eg

$1.23-2.57

At a minimum, we need to provide access to the range pattern (eg for English, `"{0}–{1}"`). That would allow people to produce patterns like $1.23-$2.47, or with some more work, like the above.

Activity

Show:
TracBot
June 30, 2018, 11:35 PM
Trac Comment 14 by —2018-04-28T08:10:43.415Z

Related: #10994

TracBot
June 30, 2018, 11:35 PM
Trac Comment 15 by —2018-04-28T08:12:12.603Z

Related: #10985

TracBot
June 30, 2018, 11:35 PM
Trac Comment 16 by —2018-05-15T20:10:26.760Z

Possible API:

where `Range` extends `Number`. I like this option because it means easy integration with MessageFormat.

We can provide one overload for API users who don't want to create a Range object:

The range style can be encoded into a two-dimensional enum:

 

= Standard =

= Collapse =

 

= Range(3, 5) =

= Range(5, 5) =

= Range(3, 5) =

= Range(5, 5) =

= Narrow =

$3 – $5

$5

$3–5

$5

= Short =

$3 – $5

~$5

$3–5

~$5

= Safe =

$3 – $5

null

$3–5

null

The enum itself can look like this:

and it can be fed as an option like this:

Comments?

Shane Carr
July 26, 2018, 8:35 AM

The two axes could reasonably be taken as two separate orthogonal settings.

and then

Or, they could be one option with nested settings, similar to Precision and Notation:

Shane Carr
September 7, 2018, 12:21 PM

This API has been proposed and accepted.

Fixed

Assignee

Shane Carr

Reporter

Mark Davis

Components

Reviewer

Andy Heninger

Priority

major

Time Needed

Days

Fix versions

Configure