Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ucnv_bld.h

Go to the documentation of this file.
00001 /*
00002 **********************************************************************
00003 *   Copyright (C) 1999, International Business Machines
00004 *   Corporation and others.  All Rights Reserved.
00005 **********************************************************************
00006 *
00007 *
00008 *  ucnv_bld.h:
00009 *  Contains all internal and external data structure definitions
00010 * Created & Maitained by Bertrand A. Damiba
00011 *
00012 *
00013 *
00014 * ATTENTION:
00015 * ---------
00016 * Although the data structures in this file are open and stack allocatable
00017 * we reserve the right to hide them in further releases.
00018 *
00019 *   Change history:
00020 *
00021 *   06/29/2000  helena      Major rewrite of the callback APIs.
00022 */
00023 
00024 #ifndef UCNV_BLD_H
00025 #define UCNV_BLD_H
00026 
00027 #include "unicode/utypes.h"
00028 #include "unicode/ucnv.h"
00029 #include "unicode/ucnv_err.h"
00030 #include "ucnvmbcs.h"
00031 
00032 /* size of the overflow buffers in UConverter, enough for escaping callbacks */
00033 #define UCNV_ERROR_BUFFER_LENGTH 32
00034 
00035 #define UCNV_MAX_SUBCHAR_LEN 4
00036 #define UCNV_MAX_AMBIGUOUSCCSIDS 5
00037 
00038 /* ### move the following typedef and array into implementation files! */
00039 typedef struct
00040 {
00041     int32_t ccsid;
00042     UChar mismapped;
00043     UChar replacement;
00044 } UAmbiguousConverter;
00045 
00046 static const UAmbiguousConverter UCNV_AMBIGUOUSCONVERTERS[UCNV_MAX_AMBIGUOUSCCSIDS] =
00047 {
00048     { 943, 0x00A5, 0x005C },
00049     { 949, 0x20A9, 0x005C },
00050     { 1361, 0x20A9, 0x005C },
00051     { 942, 0x00A5, 0x005C },
00052     { 1363, 0x20A9, 0x005C }
00053 };
00054 
00055 
00056 U_CDECL_BEGIN /* We must declare the following as 'extern "C"' so that if ucnv
00057                  itself is compiled under C++, the linkage of the funcptrs will
00058                  work.
00059               */
00060 
00061 union UConverterTable;
00062 typedef union UConverterTable UConverterTable;
00063 
00064 struct UConverterImpl;
00065 typedef struct UConverterImpl UConverterImpl;
00066 
00067 typedef struct UConverterStaticData {   /* +offset: size */
00068     uint32_t structSize;                /* +0: 4 Size of this structure */
00069     
00070     char name 
00071       [UCNV_MAX_CONVERTER_NAME_LENGTH]; /* +4: 60  internal name of the converter- invariant chars */
00072 
00073     int32_t codepage;               /* +64: 4 codepage # (now IBM-$codepage) */
00074 
00075     int8_t platform;                /* +68: 1 platform of the converter (only IBM now) */
00076     int8_t conversionType;          /* +69: 1 conversion type */
00077 
00078     int8_t minBytesPerChar;         /* +70: 1 Minimum # bytes per char in this codepage */
00079     int8_t maxBytesPerChar;         /* +71: 1 Maximum # bytes per char in this codepage */
00080 
00081     uint8_t subChar[UCNV_MAX_SUBCHAR_LEN]; /* +72: 4  [note:  4 and 8 byte boundary] */
00082     int8_t subCharLen;              /* +76: 1 */
00083     
00084     uint8_t hasToUnicodeFallback;   /* +77: 1 UBool needs to be changed to UBool to be consistent across platform */
00085     uint8_t hasFromUnicodeFallback; /* +78: 1 */
00086     uint8_t reserved[21];           /* +79: 21 to round out the structure */
00087                                     /* total size: 100 */
00088 } UConverterStaticData;
00089 
00090 /*
00091  * Defines the UConverterSharedData struct,
00092  * the immutable, shared part of UConverter.
00093  */
00094 struct UConverterSharedData {
00095     uint32_t structSize;            /* Size of this structure */
00096     uint32_t referenceCounter;      /* used to count number of clients, 0xffffffff for static SharedData */
00097 
00098     const void *dataMemory;         /* from udata_openChoice() */
00099     UConverterTable *table;         /* Pointer to conversion data */
00100 
00101     const UConverterStaticData *staticData; /* pointer to the static (non changing) data. */
00102     UBool                staticDataOwned; /* T if we own the staticData */
00103     const UConverterImpl *impl;     /* vtable-style struct of mostly function pointers */
00104 
00105     /*initial values of some members of the mutable part of object */
00106     uint32_t toUnicodeStatus;
00107 };
00108 
00109 
00110 /* Defines a UConverter, the lightweight mutable part the user sees */
00111 
00112 struct UConverter {
00113     uint32_t toUnicodeStatus;           /* Used to internalize stream status information */
00114     uint8_t toUBytes[7];                /* more "toU status"; keeps the bytes of the current character */
00115     int8_t toULength;                   /* number of bytes in toUBytes */
00116     uint32_t fromUnicodeStatus;
00117     UChar    fromUSurrogateLead;        /* similar to toUBytes; keeps the lead surrogate of the current character */
00118     int32_t mode;
00119     UBool  useFallback;
00120 
00121     int8_t subCharLen;                  /* length of the codepage specific character sequence */
00122     int8_t invalidCharLength;
00123     int8_t invalidUCharLength;
00124     int8_t charErrorBufferLength;       /* number of valid bytes in charErrorBuffer */
00125     int8_t UCharErrorBufferLength;      /* number of valid UChars in charErrorBuffer */
00126 
00127     uint8_t subChar[UCNV_MAX_SUBCHAR_LEN];              /* codepage specific character sequence */
00128     char invalidCharBuffer[UCNV_MAX_SUBCHAR_LEN];       /* bytes from last error/callback situation */
00129     uint8_t charErrorBuffer[UCNV_ERROR_BUFFER_LENGTH];  /* codepage output from Error functions */
00130 
00131     UChar invalidUCharBuffer[3];                        /* UChars from last error/callback situation */
00132     UChar UCharErrorBuffer[UCNV_ERROR_BUFFER_LENGTH];   /* unicode output from Error functions */
00133 
00134     /*
00135      * Error function pointer called when conversion issues
00136      * occur during a ucnv_fromUnicode call
00137      */
00138     void (*fromUCharErrorBehaviour) (void *context,
00139                                      UConverterFromUnicodeArgs *args,
00140                                      const UChar *codeUnits,
00141                                      int32_t length,
00142                                      UChar32 codePoint,
00143                                      UConverterCallbackReason reason,
00144                                      UErrorCode *);
00145     /*
00146      * Error function pointer called when conversion issues
00147      * occur during a T_UConverter_toUnicode call
00148      */
00149     void (*fromCharErrorBehaviour) (void *context,
00150                                     UConverterToUnicodeArgs *args,
00151                                     const char *codeUnits,
00152                                     int32_t length,
00153                                     UConverterCallbackReason reason,
00154                                     UErrorCode *);
00155 
00156     void *fromUContext;
00157     void *toUContext;
00158     UConverterSharedData *sharedData;   /* Pointer to the shared immutable part of the converter object */
00159 
00160     /*
00161      * currently only used to point to a struct containing UConverter used by iso 2022;
00162      * could be used by clients writing their own call back function to pass context to them
00163      */
00164     void *extraInfo;
00165 };
00166 
00167 U_CDECL_END /* end of UConverter */
00168 
00169 typedef struct
00170   {
00171     UConverter *OptGrpConverter[0x20];    /* Converter per Opt. grp. */
00172     uint8_t    OptGroup;                  /* default Opt. grp. for this LMBCS session */
00173     uint8_t    localeConverterIndex;      /* reasonable locale match for index */
00174 
00175   }
00176 UConverterDataLMBCS;
00177 
00178 #define CONVERTER_FILE_EXTENSION ".cnv"
00179 
00180 #endif /* _UCNV_BLD */

Generated at Tue Dec 5 17:55:34 2000 for ICU by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000