Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: source/i18n/quantityformatter.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/i18n/precision.cpp ('k') | source/i18n/rbnf.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/i18n/quantityformatter.cpp
diff --git a/source/i18n/quantityformatter.cpp b/source/i18n/quantityformatter.cpp
index bef509a718691f08cbd628bb98ba4fb313f8fdbf..ed80b38b500d1465db2ec2388bbba08ad9ee1fb6 100644
--- a/source/i18n/quantityformatter.cpp
+++ b/source/i18n/quantityformatter.cpp
@@ -1,6 +1,6 @@
/*
******************************************************************************
-* Copyright (C) 2014, International Business Machines
+* Copyright (C) 2014-2015, International Business Machines
* Corporation and others. All Rights Reserved.
******************************************************************************
* quantityformatter.cpp
@@ -11,11 +11,11 @@
#include "unicode/unistr.h"
#include "unicode/decimfmt.h"
#include "cstring.h"
-#include "plurrule_impl.h"
#include "unicode/plurrule.h"
#include "charstr.h"
#include "unicode/fmtable.h"
#include "unicode/fieldpos.h"
+#include "visibledigits.h"
#if !UCONFIG_NO_FORMATTING
@@ -136,13 +136,14 @@ UnicodeString &QuantityFormatter::format(
return appendTo;
}
UnicodeString count;
+ VisibleDigitsWithExponent digits;
const DecimalFormat *decFmt = dynamic_cast<const DecimalFormat *>(&fmt);
if (decFmt != NULL) {
- FixedDecimal fd = decFmt->getFixedDecimal(quantity, status);
+ decFmt->initVisibleDigitsWithExponent(quantity, digits, status);
if (U_FAILURE(status)) {
return appendTo;
}
- count = rules.select(fd);
+ count = rules.select(digits);
} else {
if (quantity.getType() == Formattable::kDouble) {
count = rules.select(quantity.getDouble());
@@ -167,10 +168,20 @@ UnicodeString &QuantityFormatter::format(
}
UnicodeString formattedNumber;
FieldPosition fpos(pos.getField());
- fmt.format(quantity, formattedNumber, fpos, status);
+ if (decFmt != NULL) {
+ decFmt->format(digits, formattedNumber, fpos, status);
+ } else {
+ fmt.format(quantity, formattedNumber, fpos, status);
+ }
const UnicodeString *params[1] = {&formattedNumber};
int32_t offsets[1];
- pattern->format(params, UPRV_LENGTHOF(params), appendTo, offsets, UPRV_LENGTHOF(offsets), status);
+ pattern->formatAndAppend(
+ params,
+ UPRV_LENGTHOF(params),
+ appendTo,
+ offsets,
+ UPRV_LENGTHOF(offsets),
+ status);
if (offsets[0] != -1) {
if (fpos.getBeginIndex() != 0 || fpos.getEndIndex() != 0) {
pos.setBeginIndex(fpos.getBeginIndex() + offsets[0]);
« no previous file with comments | « source/i18n/precision.cpp ('k') | source/i18n/rbnf.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698