summaryrefslogtreecommitdiffstats
path: root/thirdparty/icu4c/common/ulocale.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/icu4c/common/ulocale.cpp')
-rw-r--r--thirdparty/icu4c/common/ulocale.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/thirdparty/icu4c/common/ulocale.cpp b/thirdparty/icu4c/common/ulocale.cpp
index aaa17954a3..f2f81bc971 100644
--- a/thirdparty/icu4c/common/ulocale.cpp
+++ b/thirdparty/icu4c/common/ulocale.cpp
@@ -21,7 +21,10 @@ U_NAMESPACE_USE
ULocale*
ulocale_openForLocaleID(const char* localeID, int32_t length, UErrorCode* err) {
if (U_FAILURE(*err)) { return nullptr; }
- CharString str(length < 0 ? StringPiece(localeID) : StringPiece(localeID, length), *err);
+ if (length < 0) {
+ return EXTERNAL(icu::Locale::createFromName(localeID).clone());
+ }
+ CharString str(localeID, length, *err); // Make a NUL terminated copy.
if (U_FAILURE(*err)) { return nullptr; }
return EXTERNAL(icu::Locale::createFromName(str.data()).clone());
}