ucnv.h

Go to the documentation of this file.
00001 /*
00002 **********************************************************************
00003 *   Copyright (C) 1999-2012, 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 
00364 U_STABLE UConverter* U_EXPORT2 
00365 ucnv_open(const char *converterName, UErrorCode *err);
00366 
00367 
00394 U_STABLE UConverter* U_EXPORT2 
00395 ucnv_openU(const UChar *name,
00396            UErrorCode *err);
00397 
00462 U_STABLE UConverter* U_EXPORT2
00463 ucnv_openCCSID(int32_t codepage,
00464                UConverterPlatform platform,
00465                UErrorCode * err);
00466 
00497 U_STABLE UConverter* U_EXPORT2 
00498 ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err);
00499 
00537 U_STABLE UConverter * U_EXPORT2 
00538 ucnv_safeClone(const UConverter *cnv, 
00539                void             *stackBuffer,
00540                int32_t          *pBufferSize, 
00541                UErrorCode       *status);
00542 
00549 #define U_CNV_SAFECLONE_BUFFERSIZE  1024
00550 
00562 U_STABLE void  U_EXPORT2
00563 ucnv_close(UConverter * converter);
00564 
00565 #if U_SHOW_CPLUSPLUS_API
00566 
00567 U_NAMESPACE_BEGIN
00568 
00578 U_DEFINE_LOCAL_OPEN_POINTER(LocalUConverterPointer, UConverter, ucnv_close);
00579 
00580 U_NAMESPACE_END
00581 
00582 #endif
00583 
00601 U_STABLE void U_EXPORT2
00602 ucnv_getSubstChars(const UConverter *converter,
00603                    char *subChars,
00604                    int8_t *len,
00605                    UErrorCode *err);
00606 
00626 U_STABLE void U_EXPORT2
00627 ucnv_setSubstChars(UConverter *converter,
00628                    const char *subChars,
00629                    int8_t len,
00630                    UErrorCode *err);
00631 
00659 U_STABLE void U_EXPORT2
00660 ucnv_setSubstString(UConverter *cnv,
00661                     const UChar *s,
00662                     int32_t length,
00663                     UErrorCode *err);
00664 
00678 U_STABLE void U_EXPORT2
00679 ucnv_getInvalidChars(const UConverter *converter,
00680                      char *errBytes,
00681                      int8_t *len,
00682                      UErrorCode *err);
00683 
00697 U_STABLE void U_EXPORT2
00698 ucnv_getInvalidUChars(const UConverter *converter,
00699                       UChar *errUChars,
00700                       int8_t *len,
00701                       UErrorCode *err);
00702 
00710 U_STABLE void U_EXPORT2
00711 ucnv_reset(UConverter *converter);
00712 
00721 U_STABLE void U_EXPORT2 
00722 ucnv_resetToUnicode(UConverter *converter);
00723 
00732 U_STABLE void U_EXPORT2 
00733 ucnv_resetFromUnicode(UConverter *converter);
00734 
00783 U_STABLE int8_t U_EXPORT2
00784 ucnv_getMaxCharSize(const UConverter *converter);
00785 
00805 #define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \
00806      (((int32_t)(length)+10)*(int32_t)(maxCharSize))
00807 
00816 U_STABLE int8_t U_EXPORT2
00817 ucnv_getMinCharSize(const UConverter *converter);
00818 
00833 U_STABLE int32_t U_EXPORT2
00834 ucnv_getDisplayName(const UConverter *converter,
00835                     const char *displayLocale,
00836                     UChar *displayName,
00837                     int32_t displayNameCapacity,
00838                     UErrorCode *err);
00839 
00850 U_STABLE const char * U_EXPORT2 
00851 ucnv_getName(const UConverter *converter, UErrorCode *err);
00852 
00876 U_STABLE int32_t U_EXPORT2
00877 ucnv_getCCSID(const UConverter *converter,
00878               UErrorCode *err);
00879 
00890 U_STABLE UConverterPlatform U_EXPORT2
00891 ucnv_getPlatform(const UConverter *converter,
00892                  UErrorCode *err);
00893 
00902 U_STABLE UConverterType U_EXPORT2
00903 ucnv_getType(const UConverter * converter);
00904 
00920 U_STABLE void U_EXPORT2
00921 ucnv_getStarters(const UConverter* converter, 
00922                  UBool starters[256],
00923                  UErrorCode* err);
00924 
00925 
00931 typedef enum UConverterUnicodeSet {
00933     UCNV_ROUNDTRIP_SET,
00935     UCNV_ROUNDTRIP_AND_FALLBACK_SET,
00937     UCNV_SET_COUNT
00938 } UConverterUnicodeSet;
00939 
00940 
00986 U_STABLE void U_EXPORT2
00987 ucnv_getUnicodeSet(const UConverter *cnv,
00988                    USet *setFillIn,
00989                    UConverterUnicodeSet whichSet,
00990                    UErrorCode *pErrorCode);
00991 
01003 U_STABLE void U_EXPORT2
01004 ucnv_getToUCallBack (const UConverter * converter,
01005                      UConverterToUCallback *action,
01006                      const void **context);
01007 
01019 U_STABLE void U_EXPORT2
01020 ucnv_getFromUCallBack (const UConverter * converter,
01021                        UConverterFromUCallback *action,
01022                        const void **context);
01023 
01039 U_STABLE void U_EXPORT2
01040 ucnv_setToUCallBack (UConverter * converter,
01041                      UConverterToUCallback newAction,
01042                      const void* newContext,
01043                      UConverterToUCallback *oldAction,
01044                      const void** oldContext,
01045                      UErrorCode * err);
01046 
01062 U_STABLE void U_EXPORT2
01063 ucnv_setFromUCallBack (UConverter * converter,
01064                        UConverterFromUCallback newAction,
01065                        const void *newContext,
01066                        UConverterFromUCallback *oldAction,
01067                        const void **oldContext,
01068                        UErrorCode * err);
01069 
01128 U_STABLE void U_EXPORT2 
01129 ucnv_fromUnicode (UConverter * converter,
01130                   char **target,
01131                   const char *targetLimit,
01132                   const UChar ** source,
01133                   const UChar * sourceLimit,
01134                   int32_t* offsets,
01135                   UBool flush,
01136                   UErrorCode * err);
01137 
01197 U_STABLE void U_EXPORT2 
01198 ucnv_toUnicode(UConverter *converter,
01199                UChar **target,
01200                const UChar *targetLimit,
01201                const char **source,
01202                const char *sourceLimit,
01203                int32_t *offsets,
01204                UBool flush,
01205                UErrorCode *err);
01206 
01234 U_STABLE int32_t U_EXPORT2
01235 ucnv_fromUChars(UConverter *cnv,
01236                 char *dest, int32_t destCapacity,
01237                 const UChar *src, int32_t srcLength,
01238                 UErrorCode *pErrorCode);
01239 
01266 U_STABLE int32_t U_EXPORT2
01267 ucnv_toUChars(UConverter *cnv,
01268               UChar *dest, int32_t destCapacity,
01269               const char *src, int32_t srcLength,
01270               UErrorCode *pErrorCode);
01271 
01342 U_STABLE UChar32 U_EXPORT2
01343 ucnv_getNextUChar(UConverter * converter,
01344                   const char **source,
01345                   const char * sourceLimit,
01346                   UErrorCode * err);
01347 
01486 U_STABLE void U_EXPORT2
01487 ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
01488                char **target, const char *targetLimit,
01489                const char **source, const char *sourceLimit,
01490                UChar *pivotStart, UChar **pivotSource,
01491                UChar **pivotTarget, const UChar *pivotLimit,
01492                UBool reset, UBool flush,
01493                UErrorCode *pErrorCode);
01494 
01550 U_STABLE int32_t U_EXPORT2
01551 ucnv_convert(const char *toConverterName,
01552              const char *fromConverterName,
01553              char *target,
01554              int32_t targetCapacity,
01555              const char *source,
01556              int32_t sourceLength,
01557              UErrorCode *pErrorCode);
01558 
01604 U_STABLE int32_t U_EXPORT2
01605 ucnv_toAlgorithmic(UConverterType algorithmicType,
01606                    UConverter *cnv,
01607                    char *target, int32_t targetCapacity,
01608                    const char *source, int32_t sourceLength,
01609                    UErrorCode *pErrorCode);
01610 
01656 U_STABLE int32_t U_EXPORT2
01657 ucnv_fromAlgorithmic(UConverter *cnv,
01658                      UConverterType algorithmicType,
01659                      char *target, int32_t targetCapacity,
01660                      const char *source, int32_t sourceLength,
01661                      UErrorCode *pErrorCode);
01662 
01670 U_STABLE int32_t U_EXPORT2
01671 ucnv_flushCache(void);
01672 
01680 U_STABLE int32_t U_EXPORT2
01681 ucnv_countAvailable(void);
01682 
01693 U_STABLE const char* U_EXPORT2
01694 ucnv_getAvailableName(int32_t n);
01695 
01708 U_STABLE UEnumeration * U_EXPORT2
01709 ucnv_openAllNames(UErrorCode *pErrorCode);
01710 
01721 U_STABLE uint16_t U_EXPORT2 
01722 ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
01723 
01736 U_STABLE const char * U_EXPORT2 
01737 ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
01738 
01752 U_STABLE void U_EXPORT2 
01753 ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);
01754 
01778 U_STABLE UEnumeration * U_EXPORT2
01779 ucnv_openStandardNames(const char *convName,
01780                        const char *standard,
01781                        UErrorCode *pErrorCode);
01782 
01788 U_STABLE uint16_t U_EXPORT2
01789 ucnv_countStandards(void);
01790 
01798 U_STABLE const char * U_EXPORT2
01799 ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
01800 
01820 U_STABLE const char * U_EXPORT2
01821 ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
01822 
01842 U_STABLE const char * U_EXPORT2
01843 ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);
01844 
01859 U_STABLE const char * U_EXPORT2
01860 ucnv_getDefaultName(void);
01861 
01862 #ifndef U_HIDE_SYSTEM_API
01863 
01879 U_STABLE void U_EXPORT2
01880 ucnv_setDefaultName(const char *name);
01881 #endif  /* U_HIDE_SYSTEM_API */
01882 
01900 U_STABLE void U_EXPORT2
01901 ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);
01902 
01911 U_STABLE UBool U_EXPORT2
01912 ucnv_isAmbiguous(const UConverter *cnv);
01913 
01929 U_STABLE void U_EXPORT2 
01930 ucnv_setFallback(UConverter *cnv, UBool usesFallback);
01931 
01941 U_STABLE UBool U_EXPORT2 
01942 ucnv_usesFallback(const UConverter *cnv);
01943 
01973 U_STABLE const char* U_EXPORT2
01974 ucnv_detectUnicodeSignature(const char* source,
01975                             int32_t sourceLength,
01976                             int32_t *signatureLength,
01977                             UErrorCode *pErrorCode);
01978 
01990 U_STABLE int32_t U_EXPORT2
01991 ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
01992 
02004 U_STABLE int32_t U_EXPORT2
02005 ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
02006 
02022 U_STABLE UBool U_EXPORT2
02023 ucnv_isFixedWidth(UConverter *cnv, UErrorCode *status);
02024 
02025 #endif
02026 
02027 #endif
02028 /*_UCNV*/

Generated on 25 Nov 2014 for ICU 50.1.2 by  doxygen 1.4.7