ICU 4.6  4.6
ucnv.h
Go to the documentation of this file.
00001 /*
00002 **********************************************************************
00003 *   Copyright (C) 1999-2010, International Business Machines
00004 *   Corporation and others.  All Rights Reserved.
00005 **********************************************************************
00006  *  ucnv.h:
00007  *  External APIs for the ICU's codeset conversion library
00008  *  Bertrand A. Damiba
00009  *
00010  * Modification History:
00011  *
00012  *   Date        Name        Description
00013  *   04/04/99    helena      Fixed internal header inclusion.
00014  *   05/11/00    helena      Added setFallback and usesFallback APIs.
00015  *   06/29/2000  helena      Major rewrite of the callback APIs.
00016  *   12/07/2000  srl         Update of documentation
00017  */
00018 
00047 #ifndef UCNV_H
00048 #define UCNV_H
00049 
00050 #include "unicode/ucnv_err.h"
00051 #include "unicode/uenum.h"
00052 #include "unicode/localpointer.h"
00053 
00054 #ifndef __USET_H__
00055 
00065 struct USet;
00067 typedef struct USet USet;
00068 
00069 #endif
00070 
00071 #if !UCONFIG_NO_CONVERSION
00072 
00073 U_CDECL_BEGIN
00074 
00076 #define UCNV_MAX_CONVERTER_NAME_LENGTH 60
00077 
00078 #define UCNV_MAX_FULL_FILE_NAME_LENGTH (600+UCNV_MAX_CONVERTER_NAME_LENGTH)
00079 
00081 #define  UCNV_SI 0x0F
00082 
00083 #define  UCNV_SO 0x0E
00084 
00090 typedef enum {
00091     UCNV_UNSUPPORTED_CONVERTER = -1,
00092     UCNV_SBCS = 0,
00093     UCNV_DBCS = 1,
00094     UCNV_MBCS = 2,
00095     UCNV_LATIN_1 = 3,
00096     UCNV_UTF8 = 4,
00097     UCNV_UTF16_BigEndian = 5,
00098     UCNV_UTF16_LittleEndian = 6,
00099     UCNV_UTF32_BigEndian = 7,
00100     UCNV_UTF32_LittleEndian = 8,
00101     UCNV_EBCDIC_STATEFUL = 9,
00102     UCNV_ISO_2022 = 10,
00103 
00104     UCNV_LMBCS_1 = 11,
00105     UCNV_LMBCS_2, 
00106     UCNV_LMBCS_3,
00107     UCNV_LMBCS_4,
00108     UCNV_LMBCS_5,
00109     UCNV_LMBCS_6,
00110     UCNV_LMBCS_8,
00111     UCNV_LMBCS_11,
00112     UCNV_LMBCS_16,
00113     UCNV_LMBCS_17,
00114     UCNV_LMBCS_18,
00115     UCNV_LMBCS_19,
00116     UCNV_LMBCS_LAST = UCNV_LMBCS_19,
00117     UCNV_HZ,
00118     UCNV_SCSU,
00119     UCNV_ISCII,
00120     UCNV_US_ASCII,
00121     UCNV_UTF7,
00122     UCNV_BOCU1,
00123     UCNV_UTF16,
00124     UCNV_UTF32,
00125     UCNV_CESU8,
00126     UCNV_IMAP_MAILBOX,
00127 
00128     /* Number of converter types for which we have conversion routines. */
00129     UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES
00130 
00131 } UConverterType;
00132 
00142 typedef enum {
00143     UCNV_UNKNOWN = -1,
00144     UCNV_IBM = 0
00145 } UConverterPlatform;
00146 
00162 typedef void (U_EXPORT2 *UConverterToUCallback) (
00163                   const void* context,
00164                   UConverterToUnicodeArgs *args,
00165                   const char *codeUnits,
00166                   int32_t length,
00167                   UConverterCallbackReason reason,
00168                   UErrorCode *pErrorCode);
00169 
00185 typedef void (U_EXPORT2 *UConverterFromUCallback) (
00186                     const void* context,
00187                     UConverterFromUnicodeArgs *args,
00188                     const UChar* codeUnits,
00189                     int32_t length,
00190                     UChar32 codePoint,
00191                     UConverterCallbackReason reason,
00192                     UErrorCode *pErrorCode);
00193 
00194 U_CDECL_END
00195 
00201 #define UCNV_OPTION_SEP_CHAR ','
00202 
00208 #define UCNV_OPTION_SEP_STRING ","
00209 
00215 #define UCNV_VALUE_SEP_CHAR '='
00216 
00222 #define UCNV_VALUE_SEP_STRING "="
00223 
00232 #define UCNV_LOCALE_OPTION_STRING ",locale="
00233 
00245 #define UCNV_VERSION_OPTION_STRING ",version="
00246 
00257 #define UCNV_SWAP_LFNL_OPTION_STRING ",swaplfnl"
00258 
00274 U_STABLE int U_EXPORT2
00275 ucnv_compareNames(const char *name1, const char *name2);
00276 
00277 
00326 U_STABLE UConverter* U_EXPORT2 
00327 ucnv_open(const char *converterName, UErrorCode *err);
00328 
00329 
00356 U_STABLE UConverter* U_EXPORT2 
00357 ucnv_openU(const UChar *name,
00358            UErrorCode *err);
00359 
00424 U_STABLE UConverter* U_EXPORT2
00425 ucnv_openCCSID(int32_t codepage,
00426                UConverterPlatform platform,
00427                UErrorCode * err);
00428 
00459 U_STABLE UConverter* U_EXPORT2 
00460 ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err);
00461 
00499 U_STABLE UConverter * U_EXPORT2 
00500 ucnv_safeClone(const UConverter *cnv, 
00501                void             *stackBuffer,
00502                int32_t          *pBufferSize, 
00503                UErrorCode       *status);
00504 
00511 #define U_CNV_SAFECLONE_BUFFERSIZE  1024
00512 
00524 U_STABLE void  U_EXPORT2
00525 ucnv_close(UConverter * converter);
00526 
00527 #if U_SHOW_CPLUSPLUS_API
00528 
00529 U_NAMESPACE_BEGIN
00530 
00540 U_DEFINE_LOCAL_OPEN_POINTER(LocalUConverterPointer, UConverter, ucnv_close);
00541 
00542 U_NAMESPACE_END
00543 
00544 #endif
00545 
00563 U_STABLE void U_EXPORT2
00564 ucnv_getSubstChars(const UConverter *converter,
00565                    char *subChars,
00566                    int8_t *len,
00567                    UErrorCode *err);
00568 
00588 U_STABLE void U_EXPORT2
00589 ucnv_setSubstChars(UConverter *converter,
00590                    const char *subChars,
00591                    int8_t len,
00592                    UErrorCode *err);
00593 
00621 U_STABLE void U_EXPORT2
00622 ucnv_setSubstString(UConverter *cnv,
00623                     const UChar *s,
00624                     int32_t length,
00625                     UErrorCode *err);
00626 
00640 U_STABLE void U_EXPORT2
00641 ucnv_getInvalidChars(const UConverter *converter,
00642                      char *errBytes,
00643                      int8_t *len,
00644                      UErrorCode *err);
00645 
00659 U_STABLE void U_EXPORT2
00660 ucnv_getInvalidUChars(const UConverter *converter,
00661                       UChar *errUChars,
00662                       int8_t *len,
00663                       UErrorCode *err);
00664 
00672 U_STABLE void U_EXPORT2
00673 ucnv_reset(UConverter *converter);
00674 
00683 U_STABLE void U_EXPORT2 
00684 ucnv_resetToUnicode(UConverter *converter);
00685 
00694 U_STABLE void U_EXPORT2 
00695 ucnv_resetFromUnicode(UConverter *converter);
00696 
00745 U_STABLE int8_t U_EXPORT2
00746 ucnv_getMaxCharSize(const UConverter *converter);
00747 
00767 #define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \
00768      (((int32_t)(length)+10)*(int32_t)(maxCharSize))
00769 
00778 U_STABLE int8_t U_EXPORT2
00779 ucnv_getMinCharSize(const UConverter *converter);
00780 
00795 U_STABLE int32_t U_EXPORT2
00796 ucnv_getDisplayName(const UConverter *converter,
00797                     const char *displayLocale,
00798                     UChar *displayName,
00799                     int32_t displayNameCapacity,
00800                     UErrorCode *err);
00801 
00812 U_STABLE const char * U_EXPORT2 
00813 ucnv_getName(const UConverter *converter, UErrorCode *err);
00814 
00838 U_STABLE int32_t U_EXPORT2
00839 ucnv_getCCSID(const UConverter *converter,
00840               UErrorCode *err);
00841 
00852 U_STABLE UConverterPlatform U_EXPORT2
00853 ucnv_getPlatform(const UConverter *converter,
00854                  UErrorCode *err);
00855 
00864 U_STABLE UConverterType U_EXPORT2
00865 ucnv_getType(const UConverter * converter);
00866 
00882 U_STABLE void U_EXPORT2
00883 ucnv_getStarters(const UConverter* converter, 
00884                  UBool starters[256],
00885                  UErrorCode* err);
00886 
00887 
00893 typedef enum UConverterUnicodeSet {
00895     UCNV_ROUNDTRIP_SET,
00897     UCNV_ROUNDTRIP_AND_FALLBACK_SET,
00899     UCNV_SET_COUNT
00900 } UConverterUnicodeSet;
00901 
00902 
00948 U_STABLE void U_EXPORT2
00949 ucnv_getUnicodeSet(const UConverter *cnv,
00950                    USet *setFillIn,
00951                    UConverterUnicodeSet whichSet,
00952                    UErrorCode *pErrorCode);
00953 
00965 U_STABLE void U_EXPORT2
00966 ucnv_getToUCallBack (const UConverter * converter,
00967                      UConverterToUCallback *action,
00968                      const void **context);
00969 
00981 U_STABLE void U_EXPORT2
00982 ucnv_getFromUCallBack (const UConverter * converter,
00983                        UConverterFromUCallback *action,
00984                        const void **context);
00985 
01001 U_STABLE void U_EXPORT2
01002 ucnv_setToUCallBack (UConverter * converter,
01003                      UConverterToUCallback newAction,
01004                      const void* newContext,
01005                      UConverterToUCallback *oldAction,
01006                      const void** oldContext,
01007                      UErrorCode * err);
01008 
01024 U_STABLE void U_EXPORT2
01025 ucnv_setFromUCallBack (UConverter * converter,
01026                        UConverterFromUCallback newAction,
01027                        const void *newContext,
01028                        UConverterFromUCallback *oldAction,
01029                        const void **oldContext,
01030                        UErrorCode * err);
01031 
01090 U_STABLE void U_EXPORT2 
01091 ucnv_fromUnicode (UConverter * converter,
01092                   char **target,
01093                   const char *targetLimit,
01094                   const UChar ** source,
01095                   const UChar * sourceLimit,
01096                   int32_t* offsets,
01097                   UBool flush,
01098                   UErrorCode * err);
01099 
01159 U_STABLE void U_EXPORT2 
01160 ucnv_toUnicode(UConverter *converter,
01161                UChar **target,
01162                const UChar *targetLimit,
01163                const char **source,
01164                const char *sourceLimit,
01165                int32_t *offsets,
01166                UBool flush,
01167                UErrorCode *err);
01168 
01196 U_STABLE int32_t U_EXPORT2
01197 ucnv_fromUChars(UConverter *cnv,
01198                 char *dest, int32_t destCapacity,
01199                 const UChar *src, int32_t srcLength,
01200                 UErrorCode *pErrorCode);
01201 
01228 U_STABLE int32_t U_EXPORT2
01229 ucnv_toUChars(UConverter *cnv,
01230               UChar *dest, int32_t destCapacity,
01231               const char *src, int32_t srcLength,
01232               UErrorCode *pErrorCode);
01233 
01304 U_STABLE UChar32 U_EXPORT2
01305 ucnv_getNextUChar(UConverter * converter,
01306                   const char **source,
01307                   const char * sourceLimit,
01308                   UErrorCode * err);
01309 
01448 U_STABLE void U_EXPORT2
01449 ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
01450                char **target, const char *targetLimit,
01451                const char **source, const char *sourceLimit,
01452                UChar *pivotStart, UChar **pivotSource,
01453                UChar **pivotTarget, const UChar *pivotLimit,
01454                UBool reset, UBool flush,
01455                UErrorCode *pErrorCode);
01456 
01512 U_STABLE int32_t U_EXPORT2
01513 ucnv_convert(const char *toConverterName,
01514              const char *fromConverterName,
01515              char *target,
01516              int32_t targetCapacity,
01517              const char *source,
01518              int32_t sourceLength,
01519              UErrorCode *pErrorCode);
01520 
01566 U_STABLE int32_t U_EXPORT2
01567 ucnv_toAlgorithmic(UConverterType algorithmicType,
01568                    UConverter *cnv,
01569                    char *target, int32_t targetCapacity,
01570                    const char *source, int32_t sourceLength,
01571                    UErrorCode *pErrorCode);
01572 
01618 U_STABLE int32_t U_EXPORT2
01619 ucnv_fromAlgorithmic(UConverter *cnv,
01620                      UConverterType algorithmicType,
01621                      char *target, int32_t targetCapacity,
01622                      const char *source, int32_t sourceLength,
01623                      UErrorCode *pErrorCode);
01624 
01632 U_STABLE int32_t U_EXPORT2
01633 ucnv_flushCache(void);
01634 
01642 U_STABLE int32_t U_EXPORT2
01643 ucnv_countAvailable(void);
01644 
01655 U_STABLE const char* U_EXPORT2
01656 ucnv_getAvailableName(int32_t n);
01657 
01670 U_STABLE UEnumeration * U_EXPORT2
01671 ucnv_openAllNames(UErrorCode *pErrorCode);
01672 
01683 U_STABLE uint16_t U_EXPORT2 
01684 ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
01685 
01698 U_STABLE const char * U_EXPORT2 
01699 ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
01700 
01714 U_STABLE void U_EXPORT2 
01715 ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);
01716 
01740 U_STABLE UEnumeration * U_EXPORT2
01741 ucnv_openStandardNames(const char *convName,
01742                        const char *standard,
01743                        UErrorCode *pErrorCode);
01744 
01750 U_STABLE uint16_t U_EXPORT2
01751 ucnv_countStandards(void);
01752 
01760 U_STABLE const char * U_EXPORT2
01761 ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
01762 
01782 U_STABLE const char * U_EXPORT2
01783 ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
01784 
01804 U_STABLE const char * U_EXPORT2
01805 ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);
01806 
01821 U_STABLE const char * U_EXPORT2
01822 ucnv_getDefaultName(void);
01823 
01840 U_STABLE void U_EXPORT2
01841 ucnv_setDefaultName(const char *name);
01842 
01860 U_STABLE void U_EXPORT2
01861 ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);
01862 
01871 U_STABLE UBool U_EXPORT2
01872 ucnv_isAmbiguous(const UConverter *cnv);
01873 
01889 U_STABLE void U_EXPORT2 
01890 ucnv_setFallback(UConverter *cnv, UBool usesFallback);
01891 
01901 U_STABLE UBool U_EXPORT2 
01902 ucnv_usesFallback(const UConverter *cnv);
01903 
01960 U_STABLE const char* U_EXPORT2
01961 ucnv_detectUnicodeSignature(const char* source,
01962                             int32_t sourceLength,
01963                             int32_t *signatureLength,
01964                             UErrorCode *pErrorCode);
01965 
01977 U_STABLE int32_t U_EXPORT2
01978 ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
01979 
01991 U_STABLE int32_t U_EXPORT2
01992 ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
01993 
01994 #endif
01995 
01996 #endif
01997 /*_UCNV*/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines