| 1 | // © 2016 and later: Unicode, Inc. and others. | 
|---|
| 2 | // License & terms of use: http://www.unicode.org/copyright.html | 
|---|
| 3 | /* | 
|---|
| 4 | ********************************************************************** | 
|---|
| 5 | *   Copyright (C) 1999-2011, International Business Machines | 
|---|
| 6 | *   Corporation and others.  All Rights Reserved. | 
|---|
| 7 | ********************************************************************** | 
|---|
| 8 | * | 
|---|
| 9 | * | 
|---|
| 10 | *  ucnv_imp.h: | 
|---|
| 11 | *  Contains all internal and external data structure definitions | 
|---|
| 12 | * Created & Maitained by Bertrand A. Damiba | 
|---|
| 13 | * | 
|---|
| 14 | * | 
|---|
| 15 | * | 
|---|
| 16 | * ATTENTION: | 
|---|
| 17 | * --------- | 
|---|
| 18 | * Although the data structures in this file are open and stack allocatable | 
|---|
| 19 | * we reserve the right to hide them in further releases. | 
|---|
| 20 | */ | 
|---|
| 21 |  | 
|---|
| 22 | #ifndef UCNV_IMP_H | 
|---|
| 23 | #define UCNV_IMP_H | 
|---|
| 24 |  | 
|---|
| 25 | #include "unicode/utypes.h" | 
|---|
| 26 |  | 
|---|
| 27 | #if !UCONFIG_NO_CONVERSION | 
|---|
| 28 |  | 
|---|
| 29 | #include "unicode/uloc.h" | 
|---|
| 30 | #include "ucnv_bld.h" | 
|---|
| 31 |  | 
|---|
| 32 | /* | 
|---|
| 33 | * Fast check for whether a charset name is "UTF-8". | 
|---|
| 34 | * This does not recognize all of the variations that ucnv_open() | 
|---|
| 35 | * and other functions recognize, but it covers most cases. | 
|---|
| 36 | * @param name const char * charset name | 
|---|
| 37 | * @return | 
|---|
| 38 | */ | 
|---|
| 39 | #define UCNV_FAST_IS_UTF8(name) \ | 
|---|
| 40 | (((name[0]=='U' ? \ | 
|---|
| 41 | (                name[1]=='T' && name[2]=='F') : \ | 
|---|
| 42 | (name[0]=='u' && name[1]=='t' && name[2]=='f'))) \ | 
|---|
| 43 | && (name[3]=='-' ? \ | 
|---|
| 44 | (name[4]=='8' && name[5]==0) : \ | 
|---|
| 45 | (name[3]=='8' && name[4]==0))) | 
|---|
| 46 |  | 
|---|
| 47 | typedef struct { | 
|---|
| 48 | char cnvName[UCNV_MAX_CONVERTER_NAME_LENGTH]; | 
|---|
| 49 | char locale[ULOC_FULLNAME_CAPACITY]; | 
|---|
| 50 | uint32_t options; | 
|---|
| 51 | } UConverterNamePieces; | 
|---|
| 52 |  | 
|---|
| 53 | U_CFUNC UBool | 
|---|
| 54 | ucnv_canCreateConverter(const char *converterName, UErrorCode *err); | 
|---|
| 55 |  | 
|---|
| 56 | /* figures out if we need to go to file to read in the data tables. | 
|---|
| 57 | * @param converterName The name of the converter | 
|---|
| 58 | * @param err The error code | 
|---|
| 59 | * @return the newly created converter | 
|---|
| 60 | */ | 
|---|
| 61 | U_CAPI UConverter * | 
|---|
| 62 | ucnv_createConverter(UConverter *myUConverter, const char *converterName, UErrorCode * err); | 
|---|
| 63 |  | 
|---|
| 64 | /* | 
|---|
| 65 | * Open a purely algorithmic converter, specified by a type constant. | 
|---|
| 66 | * @param myUConverter  NULL, or pre-allocated UConverter structure to avoid | 
|---|
| 67 | *                      a memory allocation | 
|---|
| 68 | * @param type          requested converter type | 
|---|
| 69 | * @param locale        locale parameter, or "" | 
|---|
| 70 | * @param options       converter options bit set (default 0) | 
|---|
| 71 | * @param err           ICU error code, not tested for U_FAILURE on input | 
|---|
| 72 | *                      because this is an internal function | 
|---|
| 73 | * @internal | 
|---|
| 74 | */ | 
|---|
| 75 | U_CFUNC UConverter * | 
|---|
| 76 | ucnv_createAlgorithmicConverter(UConverter *myUConverter, | 
|---|
| 77 | UConverterType type, | 
|---|
| 78 | const char *locale, uint32_t options, | 
|---|
| 79 | UErrorCode *err); | 
|---|
| 80 |  | 
|---|
| 81 | /* | 
|---|
| 82 | * Creates a converter from shared data. | 
|---|
| 83 | * Adopts mySharedConverterData: No matter what happens, the caller must not | 
|---|
| 84 | * unload mySharedConverterData, except via ucnv_close(return value) | 
|---|
| 85 | * if this function is successful. | 
|---|
| 86 | */ | 
|---|
| 87 | U_CFUNC UConverter * | 
|---|
| 88 | ucnv_createConverterFromSharedData(UConverter *myUConverter, | 
|---|
| 89 | UConverterSharedData *mySharedConverterData, | 
|---|
| 90 | UConverterLoadArgs *pArgs, | 
|---|
| 91 | UErrorCode *err); | 
|---|
| 92 |  | 
|---|
| 93 | U_CFUNC UConverter * | 
|---|
| 94 | ucnv_createConverterFromPackage(const char *packageName, const char *converterName, UErrorCode *err); | 
|---|
| 95 |  | 
|---|
| 96 | /** | 
|---|
| 97 | * Load a converter but do not create a UConverter object. | 
|---|
| 98 | * Simply return the UConverterSharedData. | 
|---|
| 99 | * Performs alias lookup etc. | 
|---|
| 100 | * The UConverterNamePieces need not be initialized | 
|---|
| 101 | * before calling this function. | 
|---|
| 102 | * The UConverterLoadArgs must be initialized | 
|---|
| 103 | * before calling this function. | 
|---|
| 104 | * If the args are passed in, then the pieces must be passed in too. | 
|---|
| 105 | * In other words, the following combinations are allowed: | 
|---|
| 106 | * - pieces==NULL && args==NULL | 
|---|
| 107 | * - pieces!=NULL && args==NULL | 
|---|
| 108 | * - pieces!=NULL && args!=NULL | 
|---|
| 109 | * @internal | 
|---|
| 110 | */ | 
|---|
| 111 | U_CFUNC UConverterSharedData * | 
|---|
| 112 | ucnv_loadSharedData(const char *converterName, | 
|---|
| 113 | UConverterNamePieces *pieces, | 
|---|
| 114 | UConverterLoadArgs *pArgs, | 
|---|
| 115 | UErrorCode * err); | 
|---|
| 116 |  | 
|---|
| 117 | /** | 
|---|
| 118 | * This may unload the shared data in a thread safe manner. | 
|---|
| 119 | * This will only unload the data if no other converters are sharing it. | 
|---|
| 120 | */ | 
|---|
| 121 | U_CFUNC void | 
|---|
| 122 | ucnv_unloadSharedDataIfReady(UConverterSharedData *sharedData); | 
|---|
| 123 |  | 
|---|
| 124 | /** | 
|---|
| 125 | * This is a thread safe way to increment the reference count. | 
|---|
| 126 | */ | 
|---|
| 127 | U_CFUNC void | 
|---|
| 128 | ucnv_incrementRefCount(UConverterSharedData *sharedData); | 
|---|
| 129 |  | 
|---|
| 130 | /** | 
|---|
| 131 | * These are the default error handling callbacks for the charset conversion framework. | 
|---|
| 132 | * For performance reasons, they are only called to handle an error (not normally called for a reset or close). | 
|---|
| 133 | */ | 
|---|
| 134 | #define UCNV_TO_U_DEFAULT_CALLBACK ((UConverterToUCallback) UCNV_TO_U_CALLBACK_SUBSTITUTE) | 
|---|
| 135 | #define UCNV_FROM_U_DEFAULT_CALLBACK ((UConverterFromUCallback) UCNV_FROM_U_CALLBACK_SUBSTITUTE) | 
|---|
| 136 |  | 
|---|
| 137 | #endif | 
|---|
| 138 |  | 
|---|
| 139 | #endif /* _UCNV_IMP */ | 
|---|
| 140 |  | 
|---|