2 **********************************************************************
3 * Copyright (C) 1999-2011, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
9 * Contains all internal and external data structure definitions
10 * Created & Maitained by Bertrand A. Damiba
16 * Although the data structures in this file are open and stack allocatable
17 * we reserve the right to hide them in further releases.
23 #include "unicode/utypes.h"
25 #if !UCONFIG_NO_CONVERSION
27 #include "unicode/uloc.h"
31 * Fast check for whether a charset name is "UTF-8".
32 * This does not recognize all of the variations that ucnv_open()
33 * and other functions recognize, but it covers most cases.
34 * @param name const char * charset name
37 #define UCNV_FAST_IS_UTF8(name) \
39 ( name[1]=='T' && name[2]=='F') : \
40 (name[0]=='u' && name[1]=='t' && name[2]=='f'))) \
42 (name[4]=='8' && name[5]==0) : \
43 (name[3]=='8' && name[4]==0)))
46 char cnvName
[UCNV_MAX_CONVERTER_NAME_LENGTH
];
47 char locale
[ULOC_FULLNAME_CAPACITY
];
49 } UConverterNamePieces
;
52 ucnv_canCreateConverter(const char *converterName
, UErrorCode
*err
);
54 /* figures out if we need to go to file to read in the data tables.
55 * @param converterName The name of the converter
56 * @param err The error code
57 * @return the newly created converter
60 ucnv_createConverter(UConverter
*myUConverter
, const char *converterName
, UErrorCode
* err
);
63 * Open a purely algorithmic converter, specified by a type constant.
64 * @param myUConverter NULL, or pre-allocated UConverter structure to avoid
66 * @param type requested converter type
67 * @param locale locale parameter, or ""
68 * @param options converter options bit set (default 0)
69 * @param err ICU error code, not tested for U_FAILURE on input
70 * because this is an internal function
74 ucnv_createAlgorithmicConverter(UConverter
*myUConverter
,
76 const char *locale
, uint32_t options
,
80 * Creates a converter from shared data.
81 * Adopts mySharedConverterData: No matter what happens, the caller must not
82 * unload mySharedConverterData, except via ucnv_close(return value)
83 * if this function is successful.
86 ucnv_createConverterFromSharedData(UConverter
*myUConverter
,
87 UConverterSharedData
*mySharedConverterData
,
88 UConverterLoadArgs
*pArgs
,
92 ucnv_createConverterFromPackage(const char *packageName
, const char *converterName
, UErrorCode
*err
);
95 * Load a converter but do not create a UConverter object.
96 * Simply return the UConverterSharedData.
97 * Performs alias lookup etc.
98 * The UConverterNamePieces need not be initialized
99 * before calling this function.
100 * The UConverterLoadArgs must be initialized
101 * before calling this function.
102 * If the args are passed in, then the pieces must be passed in too.
103 * In other words, the following combinations are allowed:
104 * - pieces==NULL && args==NULL
105 * - pieces!=NULL && args==NULL
106 * - pieces!=NULL && args!=NULL
109 U_CFUNC UConverterSharedData
*
110 ucnv_loadSharedData(const char *converterName
,
111 UConverterNamePieces
*pieces
,
112 UConverterLoadArgs
*pArgs
,
116 * This may unload the shared data in a thread safe manner.
117 * This will only unload the data if no other converters are sharing it.
120 ucnv_unloadSharedDataIfReady(UConverterSharedData
*sharedData
);
123 * This is a thread safe way to increment the reference count.
126 ucnv_incrementRefCount(UConverterSharedData
*sharedData
);
129 * These are the default error handling callbacks for the charset conversion framework.
130 * For performance reasons, they are only called to handle an error (not normally called for a reset or close).
132 #define UCNV_TO_U_DEFAULT_CALLBACK ((UConverterToUCallback) UCNV_TO_U_CALLBACK_SUBSTITUTE)
133 #define UCNV_FROM_U_DEFAULT_CALLBACK ((UConverterFromUCallback) UCNV_FROM_U_CALLBACK_SUBSTITUTE)
137 #endif /* _UCNV_IMP */