summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/i18n/currunit.cpp
diff options
context:
space:
mode:
authorUjjwal Sharma <usharma1998@gmail.com>2019-04-23 15:35:49 +0530
committerMichaƫl Zasso <targos@protonmail.com>2019-04-25 21:37:14 +0200
commitc9b298c5eed7abec0aff02d1f67e18e5ea938fc9 (patch)
treed523c26552e0c06e0c7e17434d2b68bed2b6e9e8 /deps/icu-small/source/i18n/currunit.cpp
parent6bbb9ebf8d8da927fc71f648af4739f2d574014f (diff)
downloadandroid-node-v8-c9b298c5eed7abec0aff02d1f67e18e5ea938fc9.tar.gz
android-node-v8-c9b298c5eed7abec0aff02d1f67e18e5ea938fc9.tar.bz2
android-node-v8-c9b298c5eed7abec0aff02d1f67e18e5ea938fc9.zip
deps: update ICU to 64.2
Update the version of the bundled ICU (deps/icu-small) to ICU version 64.2 (Unicode 12, CLDR 35) Fixes: https://github.com/nodejs/node/issues/26388 PR-URL: https://github.com/nodejs/node/pull/27361 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Steven R Loomis <srloomis@us.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'deps/icu-small/source/i18n/currunit.cpp')
-rw-r--r--deps/icu-small/source/i18n/currunit.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/deps/icu-small/source/i18n/currunit.cpp b/deps/icu-small/source/i18n/currunit.cpp
index 2ece508751..39c49e468d 100644
--- a/deps/icu-small/source/i18n/currunit.cpp
+++ b/deps/icu-small/source/i18n/currunit.cpp
@@ -18,8 +18,10 @@
#include "unicode/ustring.h"
#include "cstring.h"
#include "uinvchar.h"
+#include "charstr.h"
static constexpr char16_t kDefaultCurrency[] = u"XXX";
+static constexpr char kDefaultCurrency8[] = "XXX";
U_NAMESPACE_BEGIN
@@ -50,6 +52,30 @@ CurrencyUnit::CurrencyUnit(ConstChar16Ptr _isoCode, UErrorCode& ec) {
initCurrency(simpleIsoCode);
}
+CurrencyUnit::CurrencyUnit(StringPiece _isoCode, UErrorCode& ec) {
+ // Note: unlike the old constructor, reject empty arguments with an error.
+ char isoCodeBuffer[4];
+ const char* isoCodeToUse;
+ // uprv_memchr checks that the string contains no internal NULs
+ if (_isoCode.length() != 3 || uprv_memchr(_isoCode.data(), 0, 3) != nullptr) {
+ isoCodeToUse = kDefaultCurrency8;
+ ec = U_ILLEGAL_ARGUMENT_ERROR;
+ } else if (!uprv_isInvariantString(_isoCode.data(), 3)) {
+ // TODO: Perform a more strict ASCII check like in ICU4J isAlpha3Code?
+ isoCodeToUse = kDefaultCurrency8;
+ ec = U_INVARIANT_CONVERSION_ERROR;
+ } else {
+ // Have to use isoCodeBuffer to ensure the string is NUL-terminated
+ uprv_strncpy(isoCodeBuffer, _isoCode.data(), 3);
+ isoCodeBuffer[3] = 0;
+ isoCodeToUse = isoCodeBuffer;
+ }
+ // TODO: Perform uppercasing here like in ICU4J Currency.getInstance()?
+ u_charsToUChars(isoCodeToUse, isoCode, 3);
+ isoCode[3] = 0;
+ initCurrency(isoCodeToUse);
+}
+
CurrencyUnit::CurrencyUnit(const CurrencyUnit& other) : MeasureUnit(other) {
u_strcpy(isoCode, other.isoCode);
}