ICU-20954 Fix currency spacing in suffix.

This commit is contained in:
Shane Carr 2020-01-29 18:33:14 -08:00 committed by Shane F. Carr
parent c0a7ecc790
commit 9eca171a39
7 changed files with 47 additions and 26 deletions

View File

@ -358,7 +358,7 @@ CurrencySpacingEnabledModifier::CurrencySpacingEnabledModifier(const FormattedSt
fAfterPrefixInsert.setToBogus();
}
if (suffix.length() > 0 && suffix.fieldAt(0) == Field(UFIELD_CATEGORY_NUMBER, UNUM_CURRENCY_FIELD)) {
int suffixCp = suffix.getLastCodePoint();
int suffixCp = suffix.getFirstCodePoint();
UnicodeSet suffixUnicodeSet = getUnicodeSet(symbols, IN_CURRENCY, SUFFIX, status);
if (suffixUnicodeSet.contains(suffixCp)) {
fBeforeSuffixUnicodeSet = getUnicodeSet(symbols, IN_NUMBER, SUFFIX, status);

View File

@ -95,6 +95,7 @@ class NumberFormatterApiTest : public IntlTestWithFieldPosition {
CurrencyUnit ESP;
CurrencyUnit PTE;
CurrencyUnit RON;
CurrencyUnit CNY;
MeasureUnit METER;
MeasureUnit DAY;

View File

@ -33,6 +33,7 @@ NumberFormatterApiTest::NumberFormatterApiTest(UErrorCode& status)
ESP(u"ESP", status),
PTE(u"PTE", status),
RON(u"RON", status),
CNY(u"CNY", status),
FRENCH_SYMBOLS(Locale::getFrench(), status),
SWISS_SYMBOLS(Locale("de-CH"), status),
MYANMAR_SYMBOLS(Locale("my"), status) {
@ -893,6 +894,15 @@ void NumberFormatterApiTest::unitCurrency() {
Locale("ro-RO"),
24,
u"24,00 lei românești");
assertFormatSingle(
u"Currency spacing in suffix (ICU-20954)",
u"currency/CNY",
u"currency/CNY",
NumberFormatter::with().unit(CNY),
Locale("lu"),
123.12,
u"123,12 CN¥");
}
void NumberFormatterApiTest::unitPercent() {

View File

@ -951,7 +951,7 @@ compact-short currency/EUR sign-accounting-except-zero
bn-BD
০€
+৯২ হা€
(.২২ €)
(.২২€)
compact-short measure-unit/length-furlong sign-accounting-except-zero
es-MX
@ -993,7 +993,7 @@ scientific/+ee/sign-always currency/EUR sign-accounting-except-zero
bn-BD
.E+০০€
+৯.১৮E+০৪€
(২.২২E-০১ €)
(২.২২E-০১€)
scientific/+ee/sign-always measure-unit/length-furlong sign-accounting-except-zero
es-MX
@ -3877,7 +3877,7 @@ currency/EUR unit-width-narrow sign-accounting-except-zero
bn-BD
.০০€
+৯১,৮২৭.৩৬€
(.২২ €)
(.২২€)
currency/EUR unit-width-full-name sign-accounting-except-zero
es-MX
@ -4927,7 +4927,7 @@ currency/EUR .000 sign-accounting-except-zero
bn-BD
.০০০€
+৯১,৮২৭.৩৬৪€
(.২২২ €)
(.২২২€)
currency/EUR .##/@@@+ sign-accounting-except-zero
es-MX
@ -4941,7 +4941,7 @@ currency/EUR .##/@@@+ sign-accounting-except-zero
bn-BD
০€
+৯১,৮২৭.৩৬€
(.২২২ €)
(.২২২€)
currency/EUR @@ sign-accounting-except-zero
es-MX
@ -4955,7 +4955,7 @@ currency/EUR @@ sign-accounting-except-zero
bn-BD
.০€
+৯২,০০০€
(.২২ €)
(.২২€)
measure-unit/length-furlong precision-integer sign-accounting-except-zero
es-MX
@ -5375,7 +5375,7 @@ currency/EUR rounding-mode-floor sign-accounting-except-zero
bn-BD
.০০€
+৯১,৮২৭.৩৬€
(.২৩ €)
(.২৩€)
measure-unit/length-furlong rounding-mode-floor sign-accounting-except-zero
es-MX
@ -5585,7 +5585,7 @@ currency/EUR integer-width/##00 sign-accounting-except-zero
bn-BD
.০০€
+১,৮২৭.৩৬€
(.২২ €)
(.২২€)
measure-unit/length-furlong integer-width/##00 sign-accounting-except-zero
es-MX
@ -5753,7 +5753,7 @@ currency/EUR scale/0.5 sign-accounting-except-zero
bn-BD
.০০€
+৪৫,৯১৩.৬৮€
(.১১ €)
(.১১€)
measure-unit/length-furlong scale/0.5 sign-accounting-except-zero
es-MX
@ -5879,7 +5879,7 @@ currency/EUR group-on-aligned sign-accounting-except-zero
bn-BD
.০০€
+৯১,৮২৭.৩৬€
(.২২ €)
(.২২€)
measure-unit/length-furlong group-on-aligned sign-accounting-except-zero
es-MX
@ -5963,7 +5963,7 @@ currency/EUR latin sign-accounting-except-zero
bn-BD
0.00€
+91,827.36€
(0.22 €)
(0.22€)
measure-unit/length-furlong latin sign-accounting-except-zero
es-MX
@ -6047,7 +6047,7 @@ currency/EUR sign-accounting-except-zero decimal-always
bn-BD
.০০€
+৯১,৮২৭.৩৬€
(.২২ €)
(.২২€)
measure-unit/length-furlong sign-accounting-except-zero decimal-always
es-MX

View File

@ -54,7 +54,7 @@ public class CurrencySpacingEnabledModifier extends ConstantMultiFieldModifier {
afterPrefixInsert = null;
}
if (suffix.length() > 0 && suffix.fieldAt(0) == NumberFormat.Field.CURRENCY) {
int suffixCp = suffix.getLastCodePoint();
int suffixCp = suffix.getFirstCodePoint();
UnicodeSet suffixUnicodeSet = getUnicodeSet(symbols, IN_CURRENCY, SUFFIX);
if (suffixUnicodeSet.contains(suffixCp)) {
beforeSuffixUnicodeSet = getUnicodeSet(symbols, IN_NUMBER, SUFFIX);

View File

@ -951,7 +951,7 @@ compact-short currency/EUR sign-accounting-except-zero
bn-BD
০€
+৯২ হা€
(.২২ €)
(.২২€)
compact-short measure-unit/length-furlong sign-accounting-except-zero
es-MX
@ -993,7 +993,7 @@ scientific/+ee/sign-always currency/EUR sign-accounting-except-zero
bn-BD
.E+০০€
+৯.১৮E+০৪€
(২.২২E-০১ €)
(২.২২E-০১€)
scientific/+ee/sign-always measure-unit/length-furlong sign-accounting-except-zero
es-MX
@ -3877,7 +3877,7 @@ currency/EUR unit-width-narrow sign-accounting-except-zero
bn-BD
.০০€
+৯১,৮২৭.৩৬€
(.২২ €)
(.২২€)
currency/EUR unit-width-full-name sign-accounting-except-zero
es-MX
@ -4927,7 +4927,7 @@ currency/EUR .000 sign-accounting-except-zero
bn-BD
.০০০€
+৯১,৮২৭.৩৬৪€
(.২২২ €)
(.২২২€)
currency/EUR .##/@@@+ sign-accounting-except-zero
es-MX
@ -4941,7 +4941,7 @@ currency/EUR .##/@@@+ sign-accounting-except-zero
bn-BD
০€
+৯১,৮২৭.৩৬€
(.২২২ €)
(.২২২€)
currency/EUR @@ sign-accounting-except-zero
es-MX
@ -4955,7 +4955,7 @@ currency/EUR @@ sign-accounting-except-zero
bn-BD
.০€
+৯২,০০০€
(.২২ €)
(.২২€)
measure-unit/length-furlong precision-integer sign-accounting-except-zero
es-MX
@ -5375,7 +5375,7 @@ currency/EUR rounding-mode-floor sign-accounting-except-zero
bn-BD
.০০€
+৯১,৮২৭.৩৬€
(.২৩ €)
(.২৩€)
measure-unit/length-furlong rounding-mode-floor sign-accounting-except-zero
es-MX
@ -5585,7 +5585,7 @@ currency/EUR integer-width/##00 sign-accounting-except-zero
bn-BD
.০০€
+১,৮২৭.৩৬€
(.২২ €)
(.২২€)
measure-unit/length-furlong integer-width/##00 sign-accounting-except-zero
es-MX
@ -5753,7 +5753,7 @@ currency/EUR scale/0.5 sign-accounting-except-zero
bn-BD
.০০€
+৪৫,৯১৩.৬৮€
(.১১ €)
(.১১€)
measure-unit/length-furlong scale/0.5 sign-accounting-except-zero
es-MX
@ -5879,7 +5879,7 @@ currency/EUR group-on-aligned sign-accounting-except-zero
bn-BD
.০০€
+৯১,৮২৭.৩৬€
(.২২ €)
(.২২€)
measure-unit/length-furlong group-on-aligned sign-accounting-except-zero
es-MX
@ -5963,7 +5963,7 @@ currency/EUR latin sign-accounting-except-zero
bn-BD
0.00€
+91,827.36€
(0.22 €)
(0.22€)
measure-unit/length-furlong latin sign-accounting-except-zero
es-MX
@ -6047,7 +6047,7 @@ currency/EUR sign-accounting-except-zero decimal-always
bn-BD
.০০€
+৯১,৮২৭.৩৬€
(.২২ €)
(.২২€)
measure-unit/length-furlong sign-accounting-except-zero decimal-always
es-MX

View File

@ -66,6 +66,7 @@ public class NumberFormatterApiTest {
private static final Currency ESP = Currency.getInstance("ESP");
private static final Currency PTE = Currency.getInstance("PTE");
private static final Currency RON = Currency.getInstance("RON");
private static final Currency CNY = Currency.getInstance("CNY");
@Test
public void notationSimple() {
@ -864,6 +865,15 @@ public class NumberFormatterApiTest {
ULocale.forLanguageTag("ro-RO"),
24,
"24,00 lei românești");
assertFormatSingle(
"Currency spacing in suffix (ICU-20954)",
"currency/CNY",
"currency/CNY",
NumberFormatter.with().unit(CNY),
ULocale.forLanguageTag("lu"),
123.12,
"123,12 CN¥");
}
@Test