ICU 4.8.1.1  4.8.1.1
ucnv.h
Go to the documentation of this file.
00001 /*
00002 **********************************************************************
00003 *   Copyright (C) 1999-2011, 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 {
00092     UCNV_UNSUPPORTED_CONVERTER = -1,
00094     UCNV_SBCS = 0,
00096     UCNV_DBCS = 1,
00098     UCNV_MBCS = 2,
00100     UCNV_LATIN_1 = 3,
00102     UCNV_UTF8 = 4,
00104     UCNV_UTF16_BigEndian = 5,
00106     UCNV_UTF16_LittleEndian = 6,
00108     UCNV_UTF32_BigEndian = 7,
00110     UCNV_UTF32_LittleEndian = 8,
00112     UCNV_EBCDIC_STATEFUL = 9,
00114     UCNV_ISO_2022 = 10,
00115 
00117     UCNV_LMBCS_1 = 11,
00119     UCNV_LMBCS_2, 
00121     UCNV_LMBCS_3,
00123     UCNV_LMBCS_4,
00125     UCNV_LMBCS_5,
00127     UCNV_LMBCS_6,
00129     UCNV_LMBCS_8,
00131     UCNV_LMBCS_11,
00133     UCNV_LMBCS_16,
00135     UCNV_LMBCS_17,
00137     UCNV_LMBCS_18,
00139     UCNV_LMBCS_19,
00141     UCNV_LMBCS_LAST = UCNV_LMBCS_19,
00143     UCNV_HZ,
00145     UCNV_SCSU,
00147     UCNV_ISCII,
00149     UCNV_US_ASCII,
00151     UCNV_UTF7,
00153     UCNV_BOCU1,
00155     UCNV_UTF16,
00157     UCNV_UTF32,
00159     UCNV_CESU8,
00161     UCNV_IMAP_MAILBOX,
00163     UCNV_COMPOUND_TEXT,
00164 
00165     /* Number of converter types for which we have conversion routines. */
00166     UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES
00167 } UConverterType;
00168 
00178 typedef enum {
00179     UCNV_UNKNOWN = -1,
00180     UCNV_IBM = 0
00181 } UConverterPlatform;
00182 
00198 typedef void (U_EXPORT2 *UConverterToUCallback) (
00199                   const void* context,
00200                   UConverterToUnicodeArgs *args,
00201                   const char *codeUnits,
00202                   int32_t length,
00203                   UConverterCallbackReason reason,
00204                   UErrorCode *pErrorCode);
00205 
00221 typedef void (U_EXPORT2 *UConverterFromUCallback) (
00222                     const void* context,
00223                     UConverterFromUnicodeArgs *args,
00224                     const UChar* codeUnits,
00225                     int32_t length,
00226                     UChar32 codePoint,
00227                     UConverterCallbackReason reason,
00228                     UErrorCode *pErrorCode);
00229 
00230 U_CDECL_END
00231 
00237 #define UCNV_OPTION_SEP_CHAR ','
00238 
00244 #define UCNV_OPTION_SEP_STRING ","
00245 
00251 #define UCNV_VALUE_SEP_CHAR '='
00252 
00258 #define UCNV_VALUE_SEP_STRING "="
00259 
00268 #define UCNV_LOCALE_OPTION_STRING ",locale="
00269 
00281 #define UCNV_VERSION_OPTION_STRING ",version="
00282 
00293 #define UCNV_SWAP_LFNL_OPTION_STRING ",swaplfnl"
00294 
00310 U_STABLE int U_EXPORT2
00311 ucnv_compareNames(const char *name1, const char *name2);
00312 
00313 
00362 U_STABLE UConverter* U_EXPORT2 
00363 ucnv_open(const char *converterName, UErrorCode *err);
00364 
00365 
00392 U_STABLE UConverter* U_EXPORT2 
00393 ucnv_openU(const UChar *name,
00394            UErrorCode *err);
00395 
00460 U_STABLE UConverter* U_EXPORT2
00461 ucnv_openCCSID(int32_t codepage,
00462                UConverterPlatform platform,
00463                UErrorCode * err);
00464 
00495 U_STABLE UConverter* U_EXPORT2 
00496 ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err);
00497 
00535 U_STABLE UConverter * U_EXPORT2 
00536 ucnv_safeClone(const UConverter *cnv, 
00537                void             *stackBuffer,
00538                int32_t          *pBufferSize, 
00539                UErrorCode       *status);
00540 
00547 #define U_CNV_SAFECLONE_BUFFERSIZE  1024
00548 
00560 U_STABLE void  U_EXPORT2
00561 ucnv_close(UConverter * converter);
00562 
00563 #if U_SHOW_CPLUSPLUS_API
00564 
00565 U_NAMESPACE_BEGIN
00566 
00576 U_DEFINE_LOCAL_OPEN_POINTER(LocalUConverterPointer, UConverter, ucnv_close);
00577 
00578 U_NAMESPACE_END
00579 
00580 #endif
00581 
00599 U_STABLE void U_EXPORT2
00600 ucnv_getSubstChars(const UConverter *converter,
00601                    char *subChars,
00602                    int8_t *len,
00603                    UErrorCode *err);
00604 
00624 U_STABLE void U_EXPORT2
00625 ucnv_setSubstChars(UConverter *converter,
00626                    const char *subChars,
00627                    int8_t len,
00628                    UErrorCode *err);
00629 
00657 U_STABLE void U_EXPORT2
00658 ucnv_setSubstString(UConverter *cnv,
00659                     const UChar *s,
00660                     int32_t length,
00661                     UErrorCode *err);
00662 
00676 U_STABLE void U_EXPORT2
00677 ucnv_getInvalidChars(const UConverter *converter,
00678                      char *errBytes,
00679                      int8_t *len,
00680                      UErrorCode *err);
00681 
00695 U_STABLE void U_EXPORT2
00696 ucnv_getInvalidUChars(const UConverter *converter,
00697                       UChar *errUChars,
00698                       int8_t *len,
00699                       UErrorCode *err);
00700 
00708 U_STABLE void U_EXPORT2
00709 ucnv_reset(UConverter *converter);
00710 
00719 U_STABLE void U_EXPORT2 
00720 ucnv_resetToUnicode(UConverter *converter);
00721 
00730 U_STABLE void U_EXPORT2 
00731 ucnv_resetFromUnicode(UConverter *converter);
00732 
00781 U_STABLE int8_t U_EXPORT2
00782 ucnv_getMaxCharSize(const UConverter *converter);
00783 
00803 #define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \
00804      (((int32_t)(length)+10)*(int32_t)(maxCharSize))
00805 
00814 U_STABLE int8_t U_EXPORT2
00815 ucnv_getMinCharSize(const UConverter *converter);
00816 
00831 U_STABLE int32_t U_EXPORT2
00832 ucnv_getDisplayName(const UConverter *converter,
00833                     const char *displayLocale,
00834                     UChar *displayName,
00835                     int32_t displayNameCapacity,
00836                     UErrorCode *err);
00837 
00848 U_STABLE const char * U_EXPORT2 
00849 ucnv_getName(const UConverter *converter, UErrorCode *err);
00850 
00874 U_STABLE int32_t U_EXPORT2
00875 ucnv_getCCSID(const UConverter *converter,
00876               UErrorCode *err);
00877 
00888 U_STABLE UConverterPlatform U_EXPORT2
00889 ucnv_getPlatform(const UConverter *converter,
00890                  UErrorCode *err);
00891 
00900 U_STABLE UConverterType U_EXPORT2
00901 ucnv_getType(const UConverter * converter);
00902 
00918 U_STABLE void U_EXPORT2
00919 ucnv_getStarters(const UConverter* converter, 
00920                  UBool starters[256],
00921                  UErrorCode* err);
00922 
00923 
00929 typedef enum UConverterUnicodeSet {
00931     UCNV_ROUNDTRIP_SET,
00933     UCNV_ROUNDTRIP_AND_FALLBACK_SET,
00935     UCNV_SET_COUNT
00936 } UConverterUnicodeSet;
00937 
00938 
00984 U_STABLE void U_EXPORT2
00985 ucnv_getUnicodeSet(const UConverter *cnv,
00986                    USet *setFillIn,
00987                    UConverterUnicodeSet whichSet,
00988                    UErrorCode *pErrorCode);
00989 
01001 U_STABLE void U_EXPORT2
01002 ucnv_getToUCallBack (const UConverter * converter,
01003                      UConverterToUCallback *action,
01004                      const void **context);
01005 
01017 U_STABLE void U_EXPORT2
01018 ucnv_getFromUCallBack (const UConverter * converter,
01019                        UConverterFromUCallback *action,
01020                        const void **context);
01021 
01037 U_STABLE void U_EXPORT2
01038 ucnv_setToUCallBack (UConverter * converter,
01039                      UConverterToUCallback newAction,
01040                      const void* newContext,
01041                      UConverterToUCallback *oldAction,
01042                      const void** oldContext,
01043                      UErrorCode * err);
01044 
01060 U_STABLE void U_EXPORT2
01061 ucnv_setFromUCallBack (UConverter * converter,
01062                        UConverterFromUCallback newAction,
01063                        const void *newContext,
01064                        UConverterFromUCallback *oldAction,
01065                        const void **oldContext,
01066                        UErrorCode * err);
01067 
01126 U_STABLE void U_EXPORT2 
01127 ucnv_fromUnicode (UConverter * converter,
01128                   char **target,
01129                   const char *targetLimit,
01130                   const UChar ** source,
01131                   const UChar * sourceLimit,
01132                   int32_t* offsets,
01133                   UBool flush,
01134                   UErrorCode * err);
01135 
01195 U_STABLE void U_EXPORT2 
01196 ucnv_toUnicode(UConverter *converter,
01197                UChar **target,
01198                const UChar *targetLimit,
01199                const char **source,
01200                const char *sourceLimit,
01201                int32_t *offsets,
01202                UBool flush,
01203                UErrorCode *err);
01204 
01232 U_STABLE int32_t U_EXPORT2
01233 ucnv_fromUChars(UConverter *cnv,
01234                 char *dest, int32_t destCapacity,
01235                 const UChar *src, int32_t srcLength,
01236                 UErrorCode *pErrorCode);
01237 
01264 U_STABLE int32_t U_EXPORT2
01265 ucnv_toUChars(UConverter *cnv,
01266               UChar *dest, int32_t destCapacity,
01267               const char *src, int32_t srcLength,
01268               UErrorCode *pErrorCode);
01269 
01340 U_STABLE UChar32 U_EXPORT2
01341 ucnv_getNextUChar(UConverter * converter,
01342                   const char **source,
01343                   const char * sourceLimit,
01344                   UErrorCode * err);
01345 
01484 U_STABLE void U_EXPORT2
01485 ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
01486                char **target, const char *targetLimit,
01487                const char **source, const char *sourceLimit,
01488                UChar *pivotStart, UChar **pivotSource,
01489                UChar **pivotTarget, const UChar *pivotLimit,
01490                UBool reset, UBool flush,
01491                UErrorCode *pErrorCode);
01492 
01548 U_STABLE int32_t U_EXPORT2
01549 ucnv_convert(const char *toConverterName,
01550              const char *fromConverterName,
01551              char *target,
01552              int32_t targetCapacity,
01553              const char *source,
01554              int32_t sourceLength,
01555              UErrorCode *pErrorCode);
01556 
01602 U_STABLE int32_t U_EXPORT2
01603 ucnv_toAlgorithmic(UConverterType algorithmicType,
01604                    UConverter *cnv,
01605                    char *target, int32_t targetCapacity,
01606                    const char *source, int32_t sourceLength,
01607                    UErrorCode *pErrorCode);
01608 
01654 U_STABLE int32_t U_EXPORT2
01655 ucnv_fromAlgorithmic(UConverter *cnv,
01656                      UConverterType algorithmicType,
01657                      char *target, int32_t targetCapacity,
01658                      const char *source, int32_t sourceLength,
01659                      UErrorCode *pErrorCode);
01660 
01668 U_STABLE int32_t U_EXPORT2
01669 ucnv_flushCache(void);
01670 
01678 U_STABLE int32_t U_EXPORT2
01679 ucnv_countAvailable(void);
01680 
01691 U_STABLE const char* U_EXPORT2
01692 ucnv_getAvailableName(int32_t n);
01693 
01706 U_STABLE UEnumeration * U_EXPORT2
01707 ucnv_openAllNames(UErrorCode *pErrorCode);
01708 
01719 U_STABLE uint16_t U_EXPORT2 
01720 ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
01721 
01734 U_STABLE const char * U_EXPORT2 
01735 ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
01736 
01750 U_STABLE void U_EXPORT2 
01751 ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);
01752 
01776 U_STABLE UEnumeration * U_EXPORT2
01777 ucnv_openStandardNames(const char *convName,
01778                        const char *standard,
01779                        UErrorCode *pErrorCode);
01780 
01786 U_STABLE uint16_t U_EXPORT2
01787 ucnv_countStandards(void);
01788 
01796 U_STABLE const char * U_EXPORT2
01797 ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
01798 
01818 U_STABLE const char * U_EXPORT2
01819 ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
01820 
01840 U_STABLE const char * U_EXPORT2
01841 ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);
01842 
01857 U_STABLE const char * U_EXPORT2
01858 ucnv_getDefaultName(void);
01859 
01876 U_STABLE void U_EXPORT2
01877 ucnv_setDefaultName(const char *name);
01878 
01896 U_STABLE void U_EXPORT2
01897 ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);
01898 
01907 U_STABLE UBool U_EXPORT2
01908 ucnv_isAmbiguous(const UConverter *cnv);
01909 
01925 U_STABLE void U_EXPORT2 
01926 ucnv_setFallback(UConverter *cnv, UBool usesFallback);
01927 
01937 U_STABLE UBool U_EXPORT2 
01938 ucnv_usesFallback(const UConverter *cnv);
01939 
01996 U_STABLE const char* U_EXPORT2
01997 ucnv_detectUnicodeSignature(const char* source,
01998                             int32_t sourceLength,
01999                             int32_t *signatureLength,
02000                             UErrorCode *pErrorCode);
02001 
02013 U_STABLE int32_t U_EXPORT2
02014 ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
02015 
02027 U_STABLE int32_t U_EXPORT2
02028 ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
02029 
02045 U_DRAFT UBool U_EXPORT2
02046 ucnv_isFixedWidth(UConverter *cnv, UErrorCode *status);
02047 
02048 #endif
02049 
02050 #endif
02051 /*_UCNV*/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines