1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 *
6 *   Copyright (C) 1997-2006, International Business Machines
7 *   Corporation and others.  All Rights Reserved.
8 *
9 *******************************************************************************
10 *   file name:  resbund_cnv.cpp
11 *   encoding:   UTF-8
12 *   tab size:   8 (not used)
13 *   indentation:4
14 *
15 *   created on: 2004aug25
16 *   created by: Markus W. Scherer
17 *
18 *   Character conversion functions moved here from resbund.cpp
19 */
20 
21 #include "unicode/utypes.h"
22 #include "unicode/resbund.h"
23 #include "uinvchar.h"
24 
25 U_NAMESPACE_BEGIN
26 
ResourceBundle(const UnicodeString & path,const Locale & locale,UErrorCode & error)27 ResourceBundle::ResourceBundle( const UnicodeString&    path,
28                                 const Locale&           locale,
29                                 UErrorCode&              error)
30                                 :UObject(), fLocale(NULL)
31 {
32     constructForLocale(path, locale, error);
33 }
34 
ResourceBundle(const UnicodeString & path,UErrorCode & error)35 ResourceBundle::ResourceBundle( const UnicodeString&    path,
36                                 UErrorCode&              error)
37                                 :UObject(), fLocale(NULL)
38 {
39     constructForLocale(path, Locale::getDefault(), error);
40 }
41 
42 void
constructForLocale(const UnicodeString & path,const Locale & locale,UErrorCode & error)43 ResourceBundle::constructForLocale(const UnicodeString& path,
44                                    const Locale& locale,
45                                    UErrorCode& error)
46 {
47     if (path.isEmpty()) {
48         fResource = ures_open(NULL, locale.getName(), &error);
49     }
50     else {
51         UnicodeString nullTerminatedPath(path);
52         nullTerminatedPath.append((UChar)0);
53         fResource = ures_openU(nullTerminatedPath.getBuffer(), locale.getName(), &error);
54     }
55 }
56 
57 U_NAMESPACE_END
58