We're updating the issue view to help you get more done. 

Currencies with $ decimal (PTE, CVE) have wrong field types

Description

When the currency symbol '$' is placed as the decimal separator instead of an affix, such as in currencies PTE and CVE in locale pt, we do not reflect that change in field position values.

Example code:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 { NumberFormat nf = NumberFormat.getCurrencyInstance(new ULocale("pt-CV")); nf.setCurrency(Currency.getInstance("CVE")); AttributedCharacterIterator it = nf.formatToCharacterIterator(49.99); char c = it.first(); assert c != AttributedCharacterIterator.DONE; do { String charString = "'" + c + "' (U+" + Integer.toHexString(c) + ")"; System.out.println(charString + " => " + it.getAttributes().values()); } while ((c = it.next()) != AttributedCharacterIterator.DONE); } System.out.println("- - - - -"); { LocalizedNumberFormatter lnf = NumberFormatter.with().unit(Currency.getInstance("CVE")) .locale(new ULocale("pt-CV")); AttributedCharacterIterator it = lnf.format(49.99).toCharacterIterator(); char c = it.first(); assert c != AttributedCharacterIterator.DONE; do { String charString = "'" + c + "' (U+" + Integer.toHexString(c) + ")"; System.out.println(charString + " => " + it.getAttributes().values()); } while ((c = it.next()) != AttributedCharacterIterator.DONE); }

Output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 '4' (U+34) => [com.ibm.icu.text.NumberFormat$Field(integer)] '9' (U+39) => [com.ibm.icu.text.NumberFormat$Field(integer)] '$' (U+24) => [com.ibm.icu.text.NumberFormat$Field(decimal separator)] '9' (U+39) => [com.ibm.icu.text.NumberFormat$Field(fraction)] '9' (U+39) => [com.ibm.icu.text.NumberFormat$Field(fraction)] ' ' (U+a0) => [] '​' (U+200b) => [com.ibm.icu.text.NumberFormat$Field(currency)] - - - - - '4' (U+34) => [com.ibm.icu.text.NumberFormat$Field(integer)] '9' (U+39) => [com.ibm.icu.text.NumberFormat$Field(integer)] '$' (U+24) => [com.ibm.icu.text.NumberFormat$Field(decimal separator)] '9' (U+39) => [com.ibm.icu.text.NumberFormat$Field(fraction)] '9' (U+39) => [com.ibm.icu.text.NumberFormat$Field(fraction)] ' ' (U+a0) => [] '​' (U+200b) => [com.ibm.icu.text.NumberFormat$Field(currency)]

More correct behavior would be to label the '$' as both a currency symbol and a decimal separator, and do not include the two trailing characters.

Might require some involvement from CLDR.

Status

Assignee

Shane Carr

Reporter

Shane Carr

Labels

Reviewer

None

Time Needed

None

Start date

None

Components

Fix versions

Priority

assess