michael@0: /* michael@0: ********************************************************************** michael@0: * Copyright (C) 1999-2011, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ********************************************************************** michael@0: * michael@0: * michael@0: * ucnv_imp.h: michael@0: * Contains all internal and external data structure definitions michael@0: * Created & Maitained by Bertrand A. Damiba michael@0: * michael@0: * michael@0: * michael@0: * ATTENTION: michael@0: * --------- michael@0: * Although the data structures in this file are open and stack allocatable michael@0: * we reserve the right to hide them in further releases. michael@0: */ michael@0: michael@0: #ifndef UCNV_IMP_H michael@0: #define UCNV_IMP_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_CONVERSION michael@0: michael@0: #include "unicode/uloc.h" michael@0: #include "ucnv_bld.h" michael@0: michael@0: /* michael@0: * Fast check for whether a charset name is "UTF-8". michael@0: * This does not recognize all of the variations that ucnv_open() michael@0: * and other functions recognize, but it covers most cases. michael@0: * @param name const char * charset name michael@0: * @return michael@0: */ michael@0: #define UCNV_FAST_IS_UTF8(name) \ michael@0: (((name[0]=='U' ? \ michael@0: ( name[1]=='T' && name[2]=='F') : \ michael@0: (name[0]=='u' && name[1]=='t' && name[2]=='f'))) \ michael@0: && (name[3]=='-' ? \ michael@0: (name[4]=='8' && name[5]==0) : \ michael@0: (name[3]=='8' && name[4]==0))) michael@0: michael@0: typedef struct { michael@0: char cnvName[UCNV_MAX_CONVERTER_NAME_LENGTH]; michael@0: char locale[ULOC_FULLNAME_CAPACITY]; michael@0: uint32_t options; michael@0: } UConverterNamePieces; michael@0: michael@0: U_CFUNC UBool michael@0: ucnv_canCreateConverter(const char *converterName, UErrorCode *err); michael@0: michael@0: /* figures out if we need to go to file to read in the data tables. michael@0: * @param converterName The name of the converter michael@0: * @param err The error code michael@0: * @return the newly created converter michael@0: */ michael@0: U_CAPI UConverter * michael@0: ucnv_createConverter(UConverter *myUConverter, const char *converterName, UErrorCode * err); michael@0: michael@0: /* michael@0: * Open a purely algorithmic converter, specified by a type constant. michael@0: * @param myUConverter NULL, or pre-allocated UConverter structure to avoid michael@0: * a memory allocation michael@0: * @param type requested converter type michael@0: * @param locale locale parameter, or "" michael@0: * @param options converter options bit set (default 0) michael@0: * @param err ICU error code, not tested for U_FAILURE on input michael@0: * because this is an internal function michael@0: * @internal michael@0: */ michael@0: U_CFUNC UConverter * michael@0: ucnv_createAlgorithmicConverter(UConverter *myUConverter, michael@0: UConverterType type, michael@0: const char *locale, uint32_t options, michael@0: UErrorCode *err); michael@0: michael@0: /* michael@0: * Creates a converter from shared data. michael@0: * Adopts mySharedConverterData: No matter what happens, the caller must not michael@0: * unload mySharedConverterData, except via ucnv_close(return value) michael@0: * if this function is successful. michael@0: */ michael@0: U_CFUNC UConverter * michael@0: ucnv_createConverterFromSharedData(UConverter *myUConverter, michael@0: UConverterSharedData *mySharedConverterData, michael@0: UConverterLoadArgs *pArgs, michael@0: UErrorCode *err); michael@0: michael@0: U_CFUNC UConverter * michael@0: ucnv_createConverterFromPackage(const char *packageName, const char *converterName, UErrorCode *err); michael@0: michael@0: /** michael@0: * Load a converter but do not create a UConverter object. michael@0: * Simply return the UConverterSharedData. michael@0: * Performs alias lookup etc. michael@0: * The UConverterNamePieces need not be initialized michael@0: * before calling this function. michael@0: * The UConverterLoadArgs must be initialized michael@0: * before calling this function. michael@0: * If the args are passed in, then the pieces must be passed in too. michael@0: * In other words, the following combinations are allowed: michael@0: * - pieces==NULL && args==NULL michael@0: * - pieces!=NULL && args==NULL michael@0: * - pieces!=NULL && args!=NULL michael@0: * @internal michael@0: */ michael@0: U_CFUNC UConverterSharedData * michael@0: ucnv_loadSharedData(const char *converterName, michael@0: UConverterNamePieces *pieces, michael@0: UConverterLoadArgs *pArgs, michael@0: UErrorCode * err); michael@0: michael@0: /** michael@0: * This may unload the shared data in a thread safe manner. michael@0: * This will only unload the data if no other converters are sharing it. michael@0: */ michael@0: U_CFUNC void michael@0: ucnv_unloadSharedDataIfReady(UConverterSharedData *sharedData); michael@0: michael@0: /** michael@0: * This is a thread safe way to increment the reference count. michael@0: */ michael@0: U_CFUNC void michael@0: ucnv_incrementRefCount(UConverterSharedData *sharedData); michael@0: michael@0: /** michael@0: * These are the default error handling callbacks for the charset conversion framework. michael@0: * For performance reasons, they are only called to handle an error (not normally called for a reset or close). michael@0: */ michael@0: #define UCNV_TO_U_DEFAULT_CALLBACK ((UConverterToUCallback) UCNV_TO_U_CALLBACK_SUBSTITUTE) michael@0: #define UCNV_FROM_U_DEFAULT_CALLBACK ((UConverterFromUCallback) UCNV_FROM_U_CALLBACK_SUBSTITUTE) michael@0: michael@0: #endif michael@0: michael@0: #endif /* _UCNV_IMP */