ICU-10161 trimMarksFromAffix must trim all marks; update "ar" number patterns to latest
X-SVN-Rev: 34203
This commit is contained in:
parent
e5fac0714c
commit
bcfcd53be9
@ -23,8 +23,8 @@ ar{
|
||||
NumberElements{
|
||||
arab{
|
||||
patterns{
|
||||
currencyFormat{"¤ #0.00;¤ #0.00-"}
|
||||
decimalFormat{"#0.###"}
|
||||
currencyFormat{"¤ #,##0.00"}
|
||||
decimalFormat{"#,##0.###"}
|
||||
percentFormat{"#,##0%"}
|
||||
scientificFormat{"#E0"}
|
||||
}
|
||||
@ -44,7 +44,7 @@ ar{
|
||||
default{"arab"}
|
||||
latn{
|
||||
patterns{
|
||||
currencyFormat{"¤ #,##0.00;¤ #,##0.00-"}
|
||||
currencyFormat{"¤ #,##0.00"}
|
||||
decimalFormat{"#,##0.###"}
|
||||
percentFormat{"#,##0%"}
|
||||
scientificFormat{"#E0"}
|
||||
|
@ -2904,23 +2904,24 @@ static UBool equalWithSignCompatibility(UChar32 lhs, UChar32 rhs) {
|
||||
// check for LRM 0x200E, RLM 0x200F, ALM 0x061C
|
||||
#define IS_BIDI_MARK(c) (c==0x200E || c==0x200F || c==0x061C)
|
||||
|
||||
// The following assumes any marks are at the beginning or end of the affix
|
||||
#define TRIM_BUFLEN 32
|
||||
UnicodeString& DecimalFormat::trimMarksFromAffix(const UnicodeString& affix, UnicodeString& trimmedAffix) {
|
||||
int32_t first = 0;
|
||||
int32_t last = affix.length() - 1;
|
||||
if (last > 0) {
|
||||
UChar c = affix.charAt(0);
|
||||
if (IS_BIDI_MARK(c)) {
|
||||
first++;
|
||||
}
|
||||
if (last > first) {
|
||||
c = affix.charAt(last);
|
||||
if (IS_BIDI_MARK(c)) {
|
||||
last--;
|
||||
}
|
||||
UChar trimBuf[TRIM_BUFLEN];
|
||||
int32_t affixLen = affix.length();
|
||||
int32_t affixPos, trimLen = 0;
|
||||
|
||||
for (affixPos = 0; affixPos < affixLen; affixPos++) {
|
||||
UChar c = affix.charAt(affixPos);
|
||||
if (!IS_BIDI_MARK(c)) {
|
||||
if (trimLen < TRIM_BUFLEN) {
|
||||
trimBuf[trimLen++] = c;
|
||||
} else {
|
||||
trimLen = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return trimmedAffix.setTo(affix, first, last + 1 - first);
|
||||
return (trimLen > 0)? trimmedAffix.setTo(trimBuf, trimLen): trimmedAffix.setTo(affix);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2939,6 +2940,8 @@ int32_t DecimalFormat::compareSimpleAffix(const UnicodeString& affix,
|
||||
UBool lenient) {
|
||||
int32_t start = pos;
|
||||
UnicodeString trimmedAffix;
|
||||
// For more efficiency we should keep lazily-created trimmed affixes around in
|
||||
// instance variables instead of trimming each time they are used (the next step)
|
||||
trimMarksFromAffix(affix, trimmedAffix);
|
||||
UChar32 affixChar = trimmedAffix.char32At(0);
|
||||
int32_t affixLength = trimmedAffix.length();
|
||||
|
@ -3092,7 +3092,7 @@ void NumberFormatTest::TestNumberingSystems() {
|
||||
{ "en_US@numbers=thai", 1234.567, FALSE, "\\u0E51,\\u0E52\\u0E53\\u0E54.\\u0E55\\u0E56\\u0E57" },
|
||||
{ "en_US@numbers=hebr", 5678.0, TRUE, "\\u05D4\\u05F3\\u05EA\\u05E8\\u05E2\\u05F4\\u05D7" },
|
||||
{ "en_US@numbers=arabext", 1234.567, FALSE, "\\u06F1\\u066c\\u06F2\\u06F3\\u06F4\\u066b\\u06F5\\u06F6\\u06F7" },
|
||||
{ "ar_EG", 1234.567, FALSE, "\\u0661\\u0662\\u0663\\u0664\\u066b\\u0665\\u0666\\u0667" },
|
||||
{ "ar_EG", 1234.567, FALSE, "\\u0661\\u066C\\u0662\\u0663\\u0664\\u066b\\u0665\\u0666\\u0667" },
|
||||
{ "th_TH@numbers=traditional", 1234.567, FALSE, "\\u0E51,\\u0E52\\u0E53\\u0E54.\\u0E55\\u0E56\\u0E57" }, // fall back to native per TR35
|
||||
{ "ar_MA", 1234.567, FALSE, "1.234,567" },
|
||||
{ "en_US@numbers=hanidec", 1234.567, FALSE, "\\u4e00,\\u4e8c\\u4e09\\u56db.\\u4e94\\u516d\\u4e03" },
|
||||
|
Loading…
Reference in New Issue
Block a user