summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/i18n/number_notation.cpp
diff options
context:
space:
mode:
authorSteven R. Loomis <srloomis@us.ibm.com>2017-09-21 15:31:38 -0700
committerSteven R. Loomis <srloomis@us.ibm.com>2017-11-09 18:25:58 -0800
commit44d3e17985befbd45457d5ad7f0a0387849e1b2f (patch)
treef75f2eddb868f13254b7f514875534dee616c0d6 /deps/icu-small/source/i18n/number_notation.cpp
parent3b3ceafaf922e1d79950595eaa501aa412913820 (diff)
downloadandroid-node-v8-44d3e17985befbd45457d5ad7f0a0387849e1b2f.tar.gz
android-node-v8-44d3e17985befbd45457d5ad7f0a0387849e1b2f.tar.bz2
android-node-v8-44d3e17985befbd45457d5ad7f0a0387849e1b2f.zip
deps: ICU 60 bump
- Update to released ICU 60.1, including: - CLDR 32 (many new languages and data improvements) - Unicode 10 (8,518 new characters, including four new scripts, 7,494 new Han characters, and 56 new emoji characters) - UTF-8 malformed bytes now handled according to W3C/WHATWG spec Fixes: https://github.com/nodejs/node/issues/15540 PR-URL: https://github.com/nodejs/node/pull/16876 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'deps/icu-small/source/i18n/number_notation.cpp')
-rw-r--r--deps/icu-small/source/i18n/number_notation.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/deps/icu-small/source/i18n/number_notation.cpp b/deps/icu-small/source/i18n/number_notation.cpp
new file mode 100644
index 0000000000..ff0cd9505d
--- /dev/null
+++ b/deps/icu-small/source/i18n/number_notation.cpp
@@ -0,0 +1,75 @@
+// © 2017 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING && !UPRV_INCOMPLETE_CPP11_SUPPORT
+
+#include "unicode/numberformatter.h"
+#include "number_types.h"
+
+using namespace icu;
+using namespace icu::number;
+using namespace icu::number::impl;
+
+
+ScientificNotation Notation::scientific() {
+ // NOTE: ISO C++ does not allow C99 designated initializers.
+ ScientificSettings settings;
+ settings.fEngineeringInterval = 1;
+ settings.fRequireMinInt = false;
+ settings.fMinExponentDigits = 1;
+ settings.fExponentSignDisplay = UNUM_SIGN_AUTO;
+ NotationUnion union_;
+ union_.scientific = settings;
+ return {NTN_SCIENTIFIC, union_};
+}
+
+ScientificNotation Notation::engineering() {
+ ScientificSettings settings;
+ settings.fEngineeringInterval = 3;
+ settings.fRequireMinInt = false;
+ settings.fMinExponentDigits = 1;
+ settings.fExponentSignDisplay = UNUM_SIGN_AUTO;
+ NotationUnion union_;
+ union_.scientific = settings;
+ return {NTN_SCIENTIFIC, union_};
+}
+
+Notation Notation::compactShort() {
+ NotationUnion union_;
+ union_.compactStyle = CompactStyle::UNUM_SHORT;
+ return {NTN_COMPACT, union_};
+}
+
+Notation Notation::compactLong() {
+ NotationUnion union_;
+ union_.compactStyle = CompactStyle::UNUM_LONG;
+ return {NTN_COMPACT, union_};
+}
+
+Notation Notation::simple() {
+ return {};
+}
+
+ScientificNotation
+ScientificNotation::withMinExponentDigits(int32_t minExponentDigits) const {
+ if (minExponentDigits >= 0 && minExponentDigits < kMaxIntFracSig) {
+ ScientificSettings settings = fUnion.scientific;
+ settings.fMinExponentDigits = (int8_t) minExponentDigits;
+ NotationUnion union_ = {settings};
+ return {NTN_SCIENTIFIC, union_};
+ } else {
+ return {U_NUMBER_DIGIT_WIDTH_OUTOFBOUNDS_ERROR};
+ }
+}
+
+ScientificNotation
+ScientificNotation::withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay) const {
+ ScientificSettings settings = fUnion.scientific;
+ settings.fExponentSignDisplay = exponentSignDisplay;
+ NotationUnion union_ = {settings};
+ return {NTN_SCIENTIFIC, union_};
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */