- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- Search for |

- File List
- Globals

# ucnv.h

Go to the documentation of this file.

    00001 /*
    00002 **********************************************************************
    00003 *   Copyright (C) 1999-2007, 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
    00053 #ifndef __USET_H__
    00054
    00064 struct USet;
    00066 typedef struct USet USet;
    00067
    00068 #endif
    00069
    00070 #if !UCONFIG_NO_CONVERSION
    00071
    00072 U_CDECL_BEGIN
    00073
    00075 #define UCNV_MAX_CONVERTER_NAME_LENGTH 60
    00076
    00077 #define UCNV_MAX_FULL_FILE_NAME_LENGTH (600+UCNV_MAX_CONVERTER_NAME_LENGTH)
    00078
    00080 #define  UCNV_SI 0x0F
    00081
    00082 #define  UCNV_SO 0x0E
    00083
    00089 typedef enum {
    00090     UCNV_UNSUPPORTED_CONVERTER = -1,
    00091     UCNV_SBCS = 0,
    00092     UCNV_DBCS = 1,
    00093     UCNV_MBCS = 2,
    00094     UCNV_LATIN_1 = 3,
    00095     UCNV_UTF8 = 4,
    00096     UCNV_UTF16_BigEndian = 5,
    00097     UCNV_UTF16_LittleEndian = 6,
    00098     UCNV_UTF32_BigEndian = 7,
    00099     UCNV_UTF32_LittleEndian = 8,
    00100     UCNV_EBCDIC_STATEFUL = 9,
    00101     UCNV_ISO_2022 = 10,
    00102
    00103     UCNV_LMBCS_1 = 11,
    00104     UCNV_LMBCS_2,
    00105     UCNV_LMBCS_3,
    00106     UCNV_LMBCS_4,
    00107     UCNV_LMBCS_5,
    00108     UCNV_LMBCS_6,
    00109     UCNV_LMBCS_8,
    00110     UCNV_LMBCS_11,
    00111     UCNV_LMBCS_16,
    00112     UCNV_LMBCS_17,
    00113     UCNV_LMBCS_18,
    00114     UCNV_LMBCS_19,
    00115     UCNV_LMBCS_LAST = UCNV_LMBCS_19,
    00116     UCNV_HZ,
    00117     UCNV_SCSU,
    00118     UCNV_ISCII,
    00119     UCNV_US_ASCII,
    00120     UCNV_UTF7,
    00121     UCNV_BOCU1,
    00122     UCNV_UTF16,
    00123     UCNV_UTF32,
    00124     UCNV_CESU8,
    00125     UCNV_IMAP_MAILBOX,
    00126
    00127     /* Number of converter types for which we have conversion routines. */
    00128     UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES
    00129
    00130 } UConverterType;
    00131
    00141 typedef enum {
    00142     UCNV_UNKNOWN = -1,
    00143     UCNV_IBM = 0
    00144 } UConverterPlatform;
    00145
    00161 typedef void (U_EXPORT2 *UConverterToUCallback) (
    00162                   const void* context,
    00163                   UConverterToUnicodeArgs *args,
    00164                   const char *codeUnits,
    00165                   int32_t length,
    00166                   UConverterCallbackReason reason,
    00167                   UErrorCode *pErrorCode);
    00168
    00184 typedef void (U_EXPORT2 *UConverterFromUCallback) (
    00185                     const void* context,
    00186                     UConverterFromUnicodeArgs *args,
    00187                     const UChar* codeUnits,
    00188                     int32_t length,
    00189                     UChar32 codePoint,
    00190                     UConverterCallbackReason reason,
    00191                     UErrorCode *pErrorCode);
    00192
    00193 U_CDECL_END
    00194
    00200 #define UCNV_OPTION_SEP_CHAR ','
    00201
    00207 #define UCNV_OPTION_SEP_STRING ","
    00208
    00214 #define UCNV_VALUE_SEP_CHAR '='
    00215
    00221 #define UCNV_VALUE_SEP_STRING "="
    00222
    00231 #define UCNV_LOCALE_OPTION_STRING ",locale="
    00232
    00241 #define UCNV_VERSION_OPTION_STRING ",version="
    00242
    00253 #define UCNV_SWAP_LFNL_OPTION_STRING ",swaplfnl"
    00254
    00270 U_STABLE int U_EXPORT2
    00271 ucnv_compareNames(const char *name1, const char *name2);
    00272
    00273
    00322 U_STABLE UConverter* U_EXPORT2
    00323 ucnv_open(const char *converterName, UErrorCode *err);
    00324
    00325
    00352 U_STABLE UConverter* U_EXPORT2
    00353 ucnv_openU(const UChar *name,
    00354            UErrorCode *err);
    00355
    00420 U_STABLE UConverter* U_EXPORT2
    00421 ucnv_openCCSID(int32_t codepage,
    00422                UConverterPlatform platform,
    00423                UErrorCode * err);
    00424
    00455 U_STABLE UConverter* U_EXPORT2
    00456 ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err);
    00457
    00495 U_STABLE UConverter * U_EXPORT2
    00496 ucnv_safeClone(const UConverter *cnv,
    00497                void             *stackBuffer,
    00498                int32_t          *pBufferSize,
    00499                UErrorCode       *status);
    00500
    00507 #define U_CNV_SAFECLONE_BUFFERSIZE  1024
    00508
    00520 U_STABLE void  U_EXPORT2
    00521 ucnv_close(UConverter * converter);
    00522
    00540 U_STABLE void U_EXPORT2
    00541 ucnv_getSubstChars(const UConverter *converter,
    00542                    char *subChars,
    00543                    int8_t *len,
    00544                    UErrorCode *err);
    00545
    00565 U_STABLE void U_EXPORT2
    00566 ucnv_setSubstChars(UConverter *converter,
    00567                    const char *subChars,
    00568                    int8_t len,
    00569                    UErrorCode *err);
    00570
    00598 U_STABLE void U_EXPORT2
    00599 ucnv_setSubstString(UConverter *cnv,
    00600                     const UChar *s,
    00601                     int32_t length,
    00602                     UErrorCode *err);
    00603
    00617 U_STABLE void U_EXPORT2
    00618 ucnv_getInvalidChars(const UConverter *converter,
    00619                      char *errBytes,
    00620                      int8_t *len,
    00621                      UErrorCode *err);
    00622
    00636 U_STABLE void U_EXPORT2
    00637 ucnv_getInvalidUChars(const UConverter *converter,
    00638                       UChar *errUChars,
    00639                       int8_t *len,
    00640                       UErrorCode *err);
    00641
    00649 U_STABLE void U_EXPORT2
    00650 ucnv_reset(UConverter *converter);
    00651
    00660 U_STABLE void U_EXPORT2
    00661 ucnv_resetToUnicode(UConverter *converter);
    00662
    00671 U_STABLE void U_EXPORT2
    00672 ucnv_resetFromUnicode(UConverter *converter);
    00673
    00722 U_STABLE int8_t U_EXPORT2
    00723 ucnv_getMaxCharSize(const UConverter *converter);
    00724
    00744 #define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \
    00745      (((int32_t)(length)+10)*(int32_t)(maxCharSize))
    00746
    00755 U_STABLE int8_t U_EXPORT2
    00756 ucnv_getMinCharSize(const UConverter *converter);
    00757
    00772 U_STABLE int32_t U_EXPORT2
    00773 ucnv_getDisplayName(const UConverter *converter,
    00774                     const char *displayLocale,
    00775                     UChar *displayName,
    00776                     int32_t displayNameCapacity,
    00777                     UErrorCode *err);
    00778
    00789 U_STABLE const char * U_EXPORT2
    00790 ucnv_getName(const UConverter *converter, UErrorCode *err);
    00791
    00815 U_STABLE int32_t U_EXPORT2
    00816 ucnv_getCCSID(const UConverter *converter,
    00817               UErrorCode *err);
    00818
    00829 U_STABLE UConverterPlatform U_EXPORT2
    00830 ucnv_getPlatform(const UConverter *converter,
    00831                  UErrorCode *err);
    00832
    00841 U_STABLE UConverterType U_EXPORT2
    00842 ucnv_getType(const UConverter * converter);
    00843
    00859 U_STABLE void U_EXPORT2
    00860 ucnv_getStarters(const UConverter* converter,
    00861                  UBool starters[256],
    00862                  UErrorCode* err);
    00863
    00864
    00870 typedef enum UConverterUnicodeSet {
    00872     UCNV_ROUNDTRIP_SET,
    00874     UCNV_SET_COUNT
    00875 } UConverterUnicodeSet;
    00876
    00877
    00912 U_STABLE void U_EXPORT2
    00913 ucnv_getUnicodeSet(const UConverter *cnv,
    00914                    USet *setFillIn,
    00915                    UConverterUnicodeSet whichSet,
    00916                    UErrorCode *pErrorCode);
    00917
    00929 U_STABLE void U_EXPORT2
    00930 ucnv_getToUCallBack (const UConverter * converter,
    00931                      UConverterToUCallback *action,
    00932                      const void **context);
    00933
    00945 U_STABLE void U_EXPORT2
    00946 ucnv_getFromUCallBack (const UConverter * converter,
    00947                        UConverterFromUCallback *action,
    00948                        const void **context);
    00949
    00965 U_STABLE void U_EXPORT2
    00966 ucnv_setToUCallBack (UConverter * converter,
    00967                      UConverterToUCallback newAction,
    00968                      const void* newContext,
    00969                      UConverterToUCallback *oldAction,
    00970                      const void** oldContext,
    00971                      UErrorCode * err);
    00972
    00988 U_STABLE void U_EXPORT2
    00989 ucnv_setFromUCallBack (UConverter * converter,
    00990                        UConverterFromUCallback newAction,
    00991                        const void *newContext,
    00992                        UConverterFromUCallback *oldAction,
    00993                        const void **oldContext,
    00994                        UErrorCode * err);
    00995
    01054 U_STABLE void U_EXPORT2
    01055 ucnv_fromUnicode (UConverter * converter,
    01056                   char **target,
    01057                   const char *targetLimit,
    01058                   const UChar ** source,
    01059                   const UChar * sourceLimit,
    01060                   int32_t* offsets,
    01061                   UBool flush,
    01062                   UErrorCode * err);
    01063
    01123 U_STABLE void U_EXPORT2
    01124 ucnv_toUnicode(UConverter *converter,
    01125                UChar **target,
    01126                const UChar *targetLimit,
    01127                const char **source,
    01128                const char *sourceLimit,
    01129                int32_t *offsets,
    01130                UBool flush,
    01131                UErrorCode *err);
    01132
    01160 U_STABLE int32_t U_EXPORT2
    01161 ucnv_fromUChars(UConverter *cnv,
    01162                 char *dest, int32_t destCapacity,
    01163                 const UChar *src, int32_t srcLength,
    01164                 UErrorCode *pErrorCode);
    01165
    01192 U_STABLE int32_t U_EXPORT2
    01193 ucnv_toUChars(UConverter *cnv,
    01194               UChar *dest, int32_t destCapacity,
    01195               const char *src, int32_t srcLength,
    01196               UErrorCode *pErrorCode);
    01197
    01268 U_STABLE UChar32 U_EXPORT2
    01269 ucnv_getNextUChar(UConverter * converter,
    01270                   const char **source,
    01271                   const char * sourceLimit,
    01272                   UErrorCode * err);
    01273
    01412 U_STABLE void U_EXPORT2
    01413 ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
    01414                char **target, const char *targetLimit,
    01415                const char **source, const char *sourceLimit,
    01416                UChar *pivotStart, UChar **pivotSource,
    01417                UChar **pivotTarget, const UChar *pivotLimit,
    01418                UBool reset, UBool flush,
    01419                UErrorCode *pErrorCode);
    01420
    01476 U_STABLE int32_t U_EXPORT2
    01477 ucnv_convert(const char *toConverterName,
    01478              const char *fromConverterName,
    01479              char *target,
    01480              int32_t targetCapacity,
    01481              const char *source,
    01482              int32_t sourceLength,
    01483              UErrorCode *pErrorCode);
    01484
    01530 U_STABLE int32_t U_EXPORT2
    01531 ucnv_toAlgorithmic(UConverterType algorithmicType,
    01532                    UConverter *cnv,
    01533                    char *target, int32_t targetCapacity,
    01534                    const char *source, int32_t sourceLength,
    01535                    UErrorCode *pErrorCode);
    01536
    01582 U_STABLE int32_t U_EXPORT2
    01583 ucnv_fromAlgorithmic(UConverter *cnv,
    01584                      UConverterType algorithmicType,
    01585                      char *target, int32_t targetCapacity,
    01586                      const char *source, int32_t sourceLength,
    01587                      UErrorCode *pErrorCode);
    01588
    01596 U_STABLE int32_t U_EXPORT2
    01597 ucnv_flushCache(void);
    01598
    01606 U_STABLE int32_t U_EXPORT2
    01607 ucnv_countAvailable(void);
    01608
    01619 U_STABLE const char* U_EXPORT2
    01620 ucnv_getAvailableName(int32_t n);
    01621
    01634 U_STABLE UEnumeration * U_EXPORT2
    01635 ucnv_openAllNames(UErrorCode *pErrorCode);
    01636
    01647 U_STABLE uint16_t U_EXPORT2
    01648 ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
    01649
    01662 U_STABLE const char * U_EXPORT2
    01663 ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
    01664
    01678 U_STABLE void U_EXPORT2
    01679 ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);
    01680
    01704 U_STABLE UEnumeration * U_EXPORT2
    01705 ucnv_openStandardNames(const char *convName,
    01706                        const char *standard,
    01707                        UErrorCode *pErrorCode);
    01708
    01714 U_STABLE uint16_t U_EXPORT2
    01715 ucnv_countStandards(void);
    01716
    01724 U_STABLE const char * U_EXPORT2
    01725 ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
    01726
    01746 U_STABLE const char * U_EXPORT2
    01747 ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
    01748
    01768 U_STABLE const char * U_EXPORT2
    01769 ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);
    01770
    01782 U_STABLE const char * U_EXPORT2
    01783 ucnv_getDefaultName(void);
    01784
    01797 U_STABLE void U_EXPORT2
    01798 ucnv_setDefaultName(const char *name);
    01799
    01817 U_STABLE void U_EXPORT2
    01818 ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);
    01819
    01828 U_STABLE UBool U_EXPORT2
    01829 ucnv_isAmbiguous(const UConverter *cnv);
    01830
    01846 U_STABLE void U_EXPORT2
    01847 ucnv_setFallback(UConverter *cnv, UBool usesFallback);
    01848
    01858 U_STABLE UBool U_EXPORT2
    01859 ucnv_usesFallback(const UConverter *cnv);
    01860
    01917 U_STABLE const char* U_EXPORT2
    01918 ucnv_detectUnicodeSignature(const char* source,
    01919                             int32_t sourceLength,
    01920                             int32_t *signatureLength,
    01921                             UErrorCode *pErrorCode);
    01922
    01934 U_STABLE int32_t U_EXPORT2
    01935 ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
    01936
    01948 U_STABLE int32_t U_EXPORT2
    01949 ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
    01950
    01951 #endif
    01952
    01953 #endif
    01954 /*_UCNV*/