]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/ures_cnv.c
2 *******************************************************************************
4 * Copyright (C) 1997-2006, 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
,
32 char pathBuffer
[1024];
34 char *path
= pathBuffer
;
36 if(status
==NULL
|| U_FAILURE(*status
)) {
43 length
=u_strlen(myPath
);
44 if(length
>=sizeof(pathBuffer
)) {
45 *status
=U_ILLEGAL_ARGUMENT_ERROR
;
47 } else if(uprv_isInvariantUString(myPath
, length
)) {
49 * the invariant converter is sufficient for package and tree names
50 * and is more efficient
52 u_UCharsToChars(myPath
, path
, length
+1); /* length+1 to include the NUL */
54 #if !UCONFIG_NO_CONVERSION
55 /* use the default converter to support variant-character paths */
56 UConverter
*cnv
=u_getDefaultConverter(status
);
57 length
=ucnv_fromUChars(cnv
, path
, (int32_t)sizeof(pathBuffer
), myPath
, length
, status
);
58 u_releaseDefaultConverter(cnv
);
59 if(U_FAILURE(*status
)) {
62 if(length
>=sizeof(pathBuffer
)) {
63 /* not NUL-terminated - path too long */
64 *status
=U_ILLEGAL_ARGUMENT_ERROR
;
68 /* the default converter is not available */
69 *status
=U_UNSUPPORTED_ERROR
;
75 return ures_open(path
, localeID
, status
);