]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/resbund_cnv.cpp
ICU-62108.0.1.tar.gz
[apple/icu.git] / icuSources / common / resbund_cnv.cpp
index b7eddbf3fa7147bea5f11baa4d5dff9b1df50751..45c0b399bfff459598d71c15bf491e9df3649d16 100644 (file)
@@ -1,12 +1,14 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 *******************************************************************************
 *
-*   Copyright (C) 1997-2004, International Business Machines
+*   Copyright (C) 1997-2006, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
 *   file name:  resbund_cnv.cpp
-*   encoding:   US-ASCII
+*   encoding:   UTF-8
 *   tab size:   8 (not used)
 *   indentation:4
 *
@@ -42,30 +44,13 @@ ResourceBundle::constructForLocale(const UnicodeString& path,
                                    const Locale& locale,
                                    UErrorCode& error)
 {
-    char name[300];
-
-    if(path.length() >= (int32_t)sizeof(name)) {
-        fResource = NULL;
-        error = U_ILLEGAL_ARGUMENT_ERROR;
-    } else if(!path.isEmpty()) {
-        if(uprv_isInvariantUString(path.getBuffer(), path.length())) {
-            // the invariant converter is sufficient for package and tree names
-            // and is more efficient
-            path.extract(0, INT32_MAX, name, (int32_t)sizeof(name), US_INV);
-        } else {
-#if !UCONFIG_NO_CONVERSION
-            // use the default converter to support variant-character paths
-            path.extract(name, sizeof(name), 0, error);
-#else
-            // the default converter is not available
-            fResource = NULL;
-            error = U_UNSUPPORTED_ERROR;
-            return;
-#endif
-        }
-        fResource = ures_open(name, locale.getName(), &error);
-    } else {
-        fResource = ures_open(0, locale.getName(), &error);
+    if (path.isEmpty()) {
+        fResource = ures_open(NULL, locale.getName(), &error);
+    }
+    else {
+        UnicodeString nullTerminatedPath(path);
+        nullTerminatedPath.append((UChar)0);
+        fResource = ures_openU(nullTerminatedPath.getBuffer(), locale.getName(), &error);
     }
 }