00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef UCNV_CNV_H
00019 #define UCNV_CNV_H
00020
00021 #include "unicode/utypes.h"
00022 #include "unicode/ucnv_err.h"
00023 #include "ucnv_bld.h"
00024 #include "ucnvmbcs.h"
00025 #include "ucmp8.h"
00026 #include "ucmp16.h"
00027
00028
00029 typedef struct
00030 {
00031 UChar *toUnicode;
00032 CompactByteArray fromUnicode;
00033 UChar *toUnicodeFallback;
00034 CompactByteArray fromUnicodeFallback;
00035 }
00036 UConverterSBCSTable;
00037
00038 typedef struct
00039 {
00040 CompactShortArray toUnicode;
00041 CompactShortArray fromUnicode;
00042 CompactShortArray toUnicodeFallback;
00043 CompactShortArray fromUnicodeFallback;
00044 }
00045 UConverterDBCSTable;
00046
00047 union UConverterTable
00048 {
00049 UConverterSBCSTable sbcs;
00050 UConverterDBCSTable dbcs;
00051 UConverterMBCSTable mbcs;
00052 };
00053
00054
00055 U_CDECL_BEGIN
00056
00057
00058 #define missingCharMarker 0xFFFF
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 #define FromU_CALLBACK_MACRO(context, args, codeUnits, length, codePoint, reason, err) \
00069 { \
00070 \
00071 \
00072 args->converter->fromUCharErrorBehaviour ( context, \
00073 args, \
00074 codeUnits, \
00075 length, \
00076 codePoint, \
00077 reason, \
00078 err); \
00079 myTargetIndex = args->target - (char*)myTarget; \
00080 mySourceIndex = args->source - mySource; \
00081 }
00082
00083
00084 #define ToU_CALLBACK_MACRO(context, args, codePoints, length, reason, err) \
00085 { \
00086 \
00087 args->converter->fromCharErrorBehaviour ( \
00088 context, \
00089 args, \
00090 codePoints, \
00091 length, \
00092 reason, \
00093 err); \
00094 myTargetIndex = args->target - myTarget; \
00095 mySourceIndex = args->source - (const char*)mySource; \
00096 }
00097
00098
00099 #define FromU_CALLBACK_OFFSETS_LOGIC_MACRO(context, args, codeUnits, length, codePoint, reason, err) \
00100 { \
00101 int32_t My_i = myTargetIndex; \
00102 \
00103 \
00104 args->converter->fromUCharErrorBehaviour ( \
00105 context, \
00106 args, \
00107 codeUnits, \
00108 length, \
00109 codePoint, \
00110 reason, \
00111 err); \
00112 \
00113 myTargetIndex = args->target - (char*)myTarget; \
00114 mySourceIndex = args->source - mySource; \
00115 args->offsets = saveOffsets; \
00116 for (;My_i < myTargetIndex;My_i++) args->offsets[My_i] += currentOffset; \
00117 }
00118
00119
00120 #define ToU_CALLBACK_OFFSETS_LOGIC_MACRO(context, args, codePoints, length, reason, err) \
00121 { \
00122 args->converter->fromCharErrorBehaviour ( \
00123 context, \
00124 args, \
00125 codePoints, \
00126 length, \
00127 reason, \
00128 err); \
00129 \
00130 myTargetIndex = args->target - myTarget; \
00131 mySourceIndex = args->source - (const char*)mySource; \
00132 args->offsets = saveOffsets; \
00133 for (;My_i < myTargetIndex;My_i++) {args->offsets[My_i] += currentOffset;} \
00134 }
00135
00136
00137 typedef void (*UConverterLoad) (UConverterSharedData *sharedData, const uint8_t *raw, UErrorCode *pErrorCode);
00138 typedef void (*UConverterUnload) (UConverterSharedData *sharedData);
00139
00140 typedef void (*UConverterOpen) (UConverter *cnv, const char *name, const char *locale,uint32_t options, UErrorCode *pErrorCode);
00141 typedef void (*UConverterClose) (UConverter *cnv);
00142
00143 typedef void (*UConverterReset) (UConverter *cnv);
00144
00145 typedef void (*T_ToUnicodeFunction) (UConverterToUnicodeArgs *, UErrorCode *);
00146
00147 typedef void (*T_FromUnicodeFunction) (UConverterFromUnicodeArgs *, UErrorCode *);
00148
00149 typedef UChar32 (*T_GetNextUCharFunction) (UConverterToUnicodeArgs *, UErrorCode *);
00150
00151 typedef void (*UConverterGetStarters)(const UConverter* converter,
00152 UBool starters[256],
00153 UErrorCode *pErrorCode);
00154
00155
00156
00157
00158 typedef const char * (*UConverterGetName) (const UConverter *cnv);
00159
00160 UBool CONVERSION_U_SUCCESS (UErrorCode err);
00161
00162 void flushInternalUnicodeBuffer (UConverter * _this,
00163 UChar * myTarget,
00164 int32_t * myTargetIndex,
00165 int32_t targetLength,
00166 int32_t** offsets,
00167 UErrorCode * err);
00168
00169 void flushInternalCharBuffer (UConverter * _this,
00170 char *myTarget,
00171 int32_t * myTargetIndex,
00172 int32_t targetLength,
00173 int32_t** offsets,
00174 UErrorCode * err);
00175
00192 struct UConverterImpl {
00193 UConverterType type;
00194
00195 UConverterLoad load;
00196 UConverterUnload unload;
00197
00198 UConverterOpen open;
00199 UConverterClose close;
00200 UConverterReset reset;
00201
00202 T_ToUnicodeFunction toUnicode;
00203 T_ToUnicodeFunction toUnicodeWithOffsets;
00204 T_FromUnicodeFunction fromUnicode;
00205 T_FromUnicodeFunction fromUnicodeWithOffsets;
00206 T_GetNextUCharFunction getNextUChar;
00207
00208 UConverterGetStarters getStarters;
00209 UConverterGetName getName;
00210 };
00211
00212 extern const UConverterSharedData
00213 _SBCSData, _DBCSData, _MBCSData, _Latin1Data,
00214 _UTF8Data, _UTF16BEData, _UTF16LEData, _UTF32BEData, _UTF32LEData,
00215 _EBCDICStatefulData, _ISO2022Data,
00216 _LMBCSData1,_LMBCSData2, _LMBCSData3, _LMBCSData4, _LMBCSData5, _LMBCSData6,
00217 _LMBCSData8,_LMBCSData11,_LMBCSData16,_LMBCSData17,_LMBCSData18,_LMBCSData19,_HZData;
00218
00219 U_CDECL_END
00220
00237 U_CFUNC UChar32
00238 ucnv_getUChar32KeepOverflow(UConverter *cnv, const UChar *buffer, int32_t length);
00239
00252 U_CFUNC int32_t *
00253 ucnv_updateCallbackOffsets(int32_t *offsets, int32_t length, int32_t sourceIndex);
00254
00256 #define TO_U_USE_FALLBACK(useFallback) TRUE
00257 #define UCNV_TO_U_USE_FALLBACK(cnv) TRUE
00258
00260 #define FROM_U_USE_FALLBACK(useFallback, c) ((useFallback) || (uint32_t)((c)-0xe000)<0x1900 || (uint32_t)((c)-0xf0000)<0x20000)
00261 #define UCNV_FROM_U_USE_FALLBACK(cnv, c) FROM_U_USE_FALLBACK((cnv)->useFallback, c)
00262
00263 #endif