ICU-13574 Merging trunk to branch
X-SVN-Rev: 40863
This commit is contained in:
commit
d5baa61bd2
@ -166,6 +166,7 @@ DecimalFormatSymbols::operator=(const DecimalFormatSymbols& rhs)
|
||||
uprv_strcpy(actualLocale, rhs.actualLocale);
|
||||
fIsCustomCurrencySymbol = rhs.fIsCustomCurrencySymbol;
|
||||
fIsCustomIntlCurrencySymbol = rhs.fIsCustomIntlCurrencySymbol;
|
||||
fCodePointZero = rhs.fCodePointZero;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@ -197,6 +198,7 @@ DecimalFormatSymbols::operator==(const DecimalFormatSymbols& that) const
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
// No need to check fCodePointZero since it is based on fSymbols
|
||||
return locale == that.locale &&
|
||||
uprv_strcmp(validLocale, that.validLocale) == 0 &&
|
||||
uprv_strcmp(actualLocale, that.actualLocale) == 0;
|
||||
@ -434,6 +436,20 @@ DecimalFormatSymbols::initialize(const Locale& loc, UErrorCode& status,
|
||||
// Let the monetary number separators equal the default number separators if necessary.
|
||||
sink.resolveMissingMonetarySeparators(fSymbols);
|
||||
|
||||
// Resolve codePointZero
|
||||
const UnicodeString& stringZero = getConstDigitSymbol(0);
|
||||
UChar32 tempCodePointZero = stringZero.char32At(0);
|
||||
if (u_isdigit(tempCodePointZero) && stringZero.countChar32() == 1) {
|
||||
for (int32_t i=0; i<=9; i++) {
|
||||
const UnicodeString& stringDigit = getConstDigitSymbol(i);
|
||||
if (stringDigit.char32At(0) != tempCodePointZero + i || stringDigit.countChar32() != 1) {
|
||||
tempCodePointZero = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fCodePointZero = tempCodePointZero;
|
||||
|
||||
// Obtain currency data from the currency API. This is strictly
|
||||
// for backward compatibility; we don't use DecimalFormatSymbols
|
||||
// for currency data anymore.
|
||||
|
@ -552,6 +552,8 @@ DecimalFormatSymbols::setSymbol(ENumberFormatSymbol symbol, const UnicodeString
|
||||
} else {
|
||||
fCodePointZero = -1;
|
||||
}
|
||||
} else if (symbol >= kOneDigitSymbol && symbol <= kNineDigitSymbol) {
|
||||
fCodePointZero = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -304,6 +304,34 @@ void IntlTestDecimalFormatSymbols::testDigitSymbols() {
|
||||
symbols.getConstDigitSymbol(i));
|
||||
}
|
||||
|
||||
// Check after copy
|
||||
DecimalFormatSymbols copy(symbols);
|
||||
if (osmanyaZero != copy.getCodePointZero()) {
|
||||
errln("ERROR: Code point zero be Osmanya code point zero");
|
||||
}
|
||||
for (int32_t i=0; i<=9; i++) {
|
||||
assertEquals(UnicodeString("iv. After copy at index ") + Int64ToUnicodeString(i),
|
||||
UnicodeString(osmanyaDigitStrings[i]),
|
||||
copy.getConstDigitSymbol(i));
|
||||
}
|
||||
|
||||
// Check when loaded from resource bundle
|
||||
DecimalFormatSymbols fromData(Locale("en@numbers=osma"), status);
|
||||
if (osmanyaZero != fromData.getCodePointZero()) {
|
||||
errln("ERROR: Code point zero be Osmanya code point zero");
|
||||
}
|
||||
for (int32_t i=0; i<=9; i++) {
|
||||
assertEquals(UnicodeString("v. Resource bundle at index ") + Int64ToUnicodeString(i),
|
||||
UnicodeString(osmanyaDigitStrings[i]),
|
||||
fromData.getConstDigitSymbol(i));
|
||||
}
|
||||
|
||||
// Setting a digit somewhere in the middle should invalidate codePointZero
|
||||
symbols.setSymbol(DecimalFormatSymbols::kOneDigitSymbol, u"foo", FALSE);
|
||||
if (-1 != symbols.getCodePointZero()) {
|
||||
errln("ERROR: Code point zero be invalid");
|
||||
}
|
||||
|
||||
// Reset digits to Latin
|
||||
symbols.setSymbol(
|
||||
DecimalFormatSymbols::kZeroDigitSymbol,
|
||||
@ -312,7 +340,7 @@ void IntlTestDecimalFormatSymbols::testDigitSymbols() {
|
||||
errln("ERROR: Code point zero be ASCII 0");
|
||||
}
|
||||
for (int32_t i=0; i<=9; i++) {
|
||||
assertEquals(UnicodeString("iv. ASCII Digit at index ") + Int64ToUnicodeString(i),
|
||||
assertEquals(UnicodeString("vi. ASCII Digit at index ") + Int64ToUnicodeString(i),
|
||||
UnicodeString(u'0' + i),
|
||||
symbols.getConstDigitSymbol(i));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user