]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/ures_cnv.c
2 *******************************************************************************
4 * Copyright (C) 1997-2004, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: ures_cnv.c
10 * tab size: 8 (not used)
13 * created on: 2004aug25
14 * created by: Markus W. Scherer
16 * Character conversion functions moved here from uresbund.c
19 #include "unicode/utypes.h"
20 #include "unicode/putil.h"
21 #include "unicode/ustring.h"
22 #include "unicode/ucnv.h"
23 #include "unicode/ures.h"
27 U_CAPI UResourceBundle
* U_EXPORT2
28 ures_openU(const UChar
*myPath
,
34 if(status
==NULL
|| U_FAILURE(*status
)) {
38 *status
=U_ILLEGAL_ARGUMENT_ERROR
;
42 length
=u_strlen(myPath
);
43 if(length
>=sizeof(path
)) {
44 *status
=U_ILLEGAL_ARGUMENT_ERROR
;
46 } else if(uprv_isInvariantUString(myPath
, length
)) {
48 * the invariant converter is sufficient for package and tree names
49 * and is more efficient
51 u_UCharsToChars(myPath
, path
, length
+1); /* length+1 to include the NUL */
53 #if !UCONFIG_NO_CONVERSION
54 /* use the default converter to support variant-character paths */
55 UConverter
*cnv
=u_getDefaultConverter(status
);
56 if(U_FAILURE(*status
)) {
60 length
=ucnv_fromUChars(cnv
, path
, (int32_t)sizeof(path
), myPath
, length
, status
);
61 u_releaseDefaultConverter(cnv
);
62 if(U_FAILURE(*status
)) {
65 if(length
>=sizeof(path
)) {
66 /* not NUL-terminated - path too long */
67 *status
=U_ILLEGAL_ARGUMENT_ERROR
;
71 /* the default converter is not available */
72 *status
=U_UNSUPPORTED_ERROR
;
77 return ures_open(path
, localeID
, status
);