summaryrefslogtreecommitdiff
path: root/deps/icu-small/source/common/cstr.cpp
diff options
context:
space:
mode:
authorSteven R. Loomis <srloomis@us.ibm.com>2016-10-19 17:24:31 -0700
committerSteven R. Loomis <srloomis@us.ibm.com>2016-10-31 13:42:52 -0700
commit40366df885ec75c7eeee5e7e7626212ae1a6e770 (patch)
tree488aa7a7778b2a42083883540724def7d5eb4f50 /deps/icu-small/source/common/cstr.cpp
parent03023fa7ae060c082a014f792d5d1f481a599460 (diff)
downloadandroid-node-v8-40366df885ec75c7eeee5e7e7626212ae1a6e770.tar.gz
android-node-v8-40366df885ec75c7eeee5e7e7626212ae1a6e770.tar.bz2
android-node-v8-40366df885ec75c7eeee5e7e7626212ae1a6e770.zip
deps: Intl: ICU 58 bump - small icu (BIG COMMIT)
This commit contains the ICU 58.1 delta. It is especially large because of the ICU license change, and, because the line endings were off previously. * bump to ICU 58.1 - check in small ICU source * from 58.1 final http://site.icu-project.org/download/58 Fixes: https://github.com/nodejs/node/issues/7844 PR-URL: https://github.com/nodejs/node/pull/9234 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps/icu-small/source/common/cstr.cpp')
-rw-r--r--deps/icu-small/source/common/cstr.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/deps/icu-small/source/common/cstr.cpp b/deps/icu-small/source/common/cstr.cpp
index c30719361e..356367e0bc 100644
--- a/deps/icu-small/source/common/cstr.cpp
+++ b/deps/icu-small/source/common/cstr.cpp
@@ -1,3 +1,5 @@
+// Copyright (C) 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 2015-2016, International Business Machines
@@ -6,22 +8,40 @@
* file name: charstr.cpp
*/
#include "unicode/utypes.h"
+#include "unicode/putil.h"
#include "unicode/unistr.h"
-#include "charstr.h"
#include "cstr.h"
+#include "charstr.h"
+#include "uinvchar.h"
+
U_NAMESPACE_BEGIN
CStr::CStr(const UnicodeString &in) {
UErrorCode status = U_ZERO_ERROR;
- int32_t length = in.extract(0, in.length(), NULL, (uint32_t)0);
+#if !UCONFIG_NO_CONVERSION || U_CHARSET_IS_UTF8
+ int32_t length = in.extract(0, in.length(), static_cast<char *>(NULL), static_cast<uint32_t>(0));
int32_t resultCapacity = 0;
char *buf = s.getAppendBuffer(length, length, resultCapacity, status);
if (U_SUCCESS(status)) {
in.extract(0, in.length(), buf, resultCapacity);
s.append(buf, length, status);
}
+#else
+ // No conversion available. Convert any invariant characters; substitute '?' for the rest.
+ // Note: can't just call u_UCharsToChars() or CharString.appendInvariantChars() on the
+ // whole string because they require that the entire input be invariant.
+ char buf[2];
+ for (int i=0; i<in.length(); i = in.moveIndex32(i, 1)) {
+ if (uprv_isInvariantUString(in.getBuffer()+i, 1)) {
+ u_UCharsToChars(in.getBuffer()+i, buf, 1);
+ } else {
+ buf[0] = '?';
+ }
+ s.append(buf, 1, status);
+ }
+#endif
}
CStr::~CStr() {