00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00047 #ifndef UCNV_H
00048 #define UCNV_H
00049
00051 struct UConverter;
00052
00054 typedef struct UConverter UConverter;
00055
00056 #include "unicode/utypes.h"
00057 #include "unicode/ucnv_err.h"
00058 #include "unicode/uenum.h"
00059
00060 #ifndef __USET_H__
00061
00071 struct USet;
00072 typedef struct USet USet;
00073
00074 #endif
00075
00076 U_CDECL_BEGIN
00077
00079 #define UCNV_MAX_CONVERTER_NAME_LENGTH 60
00080
00081 #define UCNV_MAX_FULL_FILE_NAME_LENGTH (600+UCNV_MAX_CONVERTER_NAME_LENGTH)
00082
00084 #define UCNV_SI 0x0F
00085
00086 #define UCNV_SO 0x0E
00087
00093 typedef enum {
00094 UCNV_UNSUPPORTED_CONVERTER = -1,
00095 UCNV_SBCS = 0,
00096 UCNV_DBCS = 1,
00097 UCNV_MBCS = 2,
00098 UCNV_LATIN_1 = 3,
00099 UCNV_UTF8 = 4,
00100 UCNV_UTF16_BigEndian = 5,
00101 UCNV_UTF16_LittleEndian = 6,
00102 UCNV_UTF32_BigEndian = 7,
00103 UCNV_UTF32_LittleEndian = 8,
00104 UCNV_EBCDIC_STATEFUL = 9,
00105 UCNV_ISO_2022 = 10,
00106
00107 UCNV_LMBCS_1 = 11,
00108 UCNV_LMBCS_2,
00109 UCNV_LMBCS_3,
00110 UCNV_LMBCS_4,
00111 UCNV_LMBCS_5,
00112 UCNV_LMBCS_6,
00113 UCNV_LMBCS_8,
00114 UCNV_LMBCS_11,
00115 UCNV_LMBCS_16,
00116 UCNV_LMBCS_17,
00117 UCNV_LMBCS_18,
00118 UCNV_LMBCS_19,
00119 UCNV_LMBCS_LAST = UCNV_LMBCS_19,
00120 UCNV_HZ,
00121 UCNV_SCSU,
00122 UCNV_ISCII,
00123 UCNV_US_ASCII,
00124 UCNV_UTF7,
00125 UCNV_BOCU1,
00126 UCNV_UTF16,
00127 UCNV_UTF32,
00128 UCNV_CESU8,
00129 UCNV_IMAP_MAILBOX,
00130
00131
00132 UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES
00133
00134 } UConverterType;
00135
00145 typedef enum {
00146 UCNV_UNKNOWN = -1,
00147 UCNV_IBM = 0
00148 } UConverterPlatform;
00149
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 *);
00169
00182 typedef void (U_EXPORT2 *UConverterFromUCallback) (
00183 const void* context,
00184 UConverterFromUnicodeArgs *args,
00185 const UChar* codeUnits,
00186 int32_t length,
00187 UChar32 codePoint,
00188 UConverterCallbackReason reason,
00189 UErrorCode *);
00190
00191 U_CDECL_END
00192
00198 #define UCNV_OPTION_SEP_CHAR ','
00199
00205 #define UCNV_OPTION_SEP_STRING ","
00206
00212 #define UCNV_VALUE_SEP_CHAR '='
00213
00219 #define UCNV_VALUE_SEP_STRING "="
00220
00229 #define UCNV_LOCALE_OPTION_STRING ",locale="
00230
00239 #define UCNV_VERSION_OPTION_STRING ",version="
00240
00251 #define UCNV_SWAP_LFNL_OPTION_STRING ",swaplfnl"
00252
00266 U_CAPI int U_EXPORT2
00267 ucnv_compareNames(const char *name1, const char *name2);
00268
00269
00305 U_CAPI UConverter* U_EXPORT2
00306 ucnv_open(const char *converterName, UErrorCode *err);
00307
00308
00332 U_CAPI UConverter* U_EXPORT2
00333 ucnv_openU(const UChar *name,
00334 UErrorCode *err);
00335
00400 U_CAPI UConverter* U_EXPORT2
00401 ucnv_openCCSID(int32_t codepage,
00402 UConverterPlatform platform,
00403 UErrorCode * err);
00404
00435 U_CAPI UConverter* U_EXPORT2
00436 ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err);
00437
00454 U_CAPI UConverter * U_EXPORT2
00455 ucnv_safeClone(const UConverter *cnv,
00456 void *stackBuffer,
00457 int32_t *pBufferSize,
00458 UErrorCode *status);
00459
00466 #define U_CNV_SAFECLONE_BUFFERSIZE 1024
00467
00479 U_CAPI void U_EXPORT2
00480 ucnv_close(UConverter * converter);
00481
00496 U_CAPI void U_EXPORT2
00497 ucnv_getSubstChars(const UConverter *converter,
00498 char *subChars,
00499 int8_t *len,
00500 UErrorCode *err);
00501
00514 U_CAPI void U_EXPORT2
00515 ucnv_setSubstChars(UConverter *converter,
00516 const char *subChars,
00517 int8_t len,
00518 UErrorCode *err);
00519
00533 U_CAPI void U_EXPORT2
00534 ucnv_getInvalidChars(const UConverter *converter,
00535 char *errBytes,
00536 int8_t *len,
00537 UErrorCode *err);
00538
00552 U_CAPI void U_EXPORT2
00553 ucnv_getInvalidUChars(const UConverter *converter,
00554 UChar *errUChars,
00555 int8_t *len,
00556 UErrorCode *err);
00557
00565 U_CAPI void U_EXPORT2
00566 ucnv_reset(UConverter *converter);
00567
00576 U_CAPI void U_EXPORT2
00577 ucnv_resetToUnicode(UConverter *converter);
00578
00587 U_CAPI void U_EXPORT2
00588 ucnv_resetFromUnicode(UConverter *converter);
00589
00638 U_CAPI int8_t U_EXPORT2
00639 ucnv_getMaxCharSize(const UConverter *converter);
00640
00660 #define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \
00661 (((int32_t)(length)+10)*(int32_t)(maxCharSize))
00662
00671 U_CAPI int8_t U_EXPORT2
00672 ucnv_getMinCharSize(const UConverter *converter);
00673
00688 U_CAPI int32_t U_EXPORT2
00689 ucnv_getDisplayName(const UConverter *converter,
00690 const char *displayLocale,
00691 UChar *displayName,
00692 int32_t displayNameCapacity,
00693 UErrorCode *err);
00694
00705 U_CAPI const char * U_EXPORT2
00706 ucnv_getName(const UConverter *converter, UErrorCode *err);
00707
00731 U_CAPI int32_t U_EXPORT2
00732 ucnv_getCCSID(const UConverter *converter,
00733 UErrorCode *err);
00734
00745 U_CAPI UConverterPlatform U_EXPORT2
00746 ucnv_getPlatform(const UConverter *converter,
00747 UErrorCode *err);
00748
00757 U_CAPI UConverterType U_EXPORT2
00758 ucnv_getType(const UConverter * converter);
00759
00775 U_CAPI void U_EXPORT2
00776 ucnv_getStarters(const UConverter* converter,
00777 UBool starters[256],
00778 UErrorCode* err);
00779
00785 typedef enum UConverterUnicodeSet {
00787 UCNV_ROUNDTRIP_SET,
00789 UCNV_SET_COUNT
00790 } UConverterUnicodeSet;
00791
00826 U_CAPI void U_EXPORT2
00827 ucnv_getUnicodeSet(const UConverter *cnv,
00828 USet *set,
00829 UConverterUnicodeSet which,
00830 UErrorCode *pErrorCode);
00831
00843 U_CAPI void U_EXPORT2
00844 ucnv_getToUCallBack (const UConverter * converter,
00845 UConverterToUCallback *action,
00846 const void **context);
00847
00859 U_CAPI void U_EXPORT2
00860 ucnv_getFromUCallBack (const UConverter * converter,
00861 UConverterFromUCallback *action,
00862 const void **context);
00863
00879 U_CAPI void U_EXPORT2
00880 ucnv_setToUCallBack (UConverter * converter,
00881 UConverterToUCallback newAction,
00882 const void* newContext,
00883 UConverterToUCallback *oldAction,
00884 const void** oldContext,
00885 UErrorCode * err);
00886
00902 U_CAPI void U_EXPORT2
00903 ucnv_setFromUCallBack (UConverter * converter,
00904 UConverterFromUCallback newAction,
00905 const void *newContext,
00906 UConverterFromUCallback *oldAction,
00907 const void **oldContext,
00908 UErrorCode * err);
00909
00968 U_CAPI void U_EXPORT2
00969 ucnv_fromUnicode (UConverter * converter,
00970 char **target,
00971 const char *targetLimit,
00972 const UChar ** source,
00973 const UChar * sourceLimit,
00974 int32_t* offsets,
00975 UBool flush,
00976 UErrorCode * err);
00977
01037 U_CAPI void U_EXPORT2
01038 ucnv_toUnicode(UConverter *converter,
01039 UChar **target,
01040 const UChar *targetLimit,
01041 const char **source,
01042 const char *sourceLimit,
01043 int32_t *offsets,
01044 UBool flush,
01045 UErrorCode *err);
01046
01074 U_CAPI int32_t U_EXPORT2
01075 ucnv_fromUChars(UConverter *cnv,
01076 char *dest, int32_t destCapacity,
01077 const UChar *src, int32_t srcLength,
01078 UErrorCode *pErrorCode);
01079
01106 U_CAPI int32_t U_EXPORT2
01107 ucnv_toUChars(UConverter *cnv,
01108 UChar *dest, int32_t destCapacity,
01109 const char *src, int32_t srcLength,
01110 UErrorCode *pErrorCode);
01111
01182 U_CAPI UChar32 U_EXPORT2
01183 ucnv_getNextUChar(UConverter * converter,
01184 const char **source,
01185 const char * sourceLimit,
01186 UErrorCode * err);
01187
01316 U_CAPI void U_EXPORT2
01317 ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
01318 char **target, const char *targetLimit,
01319 const char **source, const char *sourceLimit,
01320 UChar *pivotStart, UChar **pivotSource,
01321 UChar **pivotTarget, const UChar *pivotLimit,
01322 UBool reset, UBool flush,
01323 UErrorCode *pErrorCode);
01324
01380 U_CAPI int32_t U_EXPORT2
01381 ucnv_convert(const char *toConverterName,
01382 const char *fromConverterName,
01383 char *target,
01384 int32_t targetCapacity,
01385 const char *source,
01386 int32_t sourceLength,
01387 UErrorCode *pErrorCode);
01388
01434 U_CAPI int32_t U_EXPORT2
01435 ucnv_toAlgorithmic(UConverterType algorithmicType,
01436 UConverter *cnv,
01437 char *target, int32_t targetCapacity,
01438 const char *source, int32_t sourceLength,
01439 UErrorCode *pErrorCode);
01440
01486 U_CAPI int32_t U_EXPORT2
01487 ucnv_fromAlgorithmic(UConverter *cnv,
01488 UConverterType algorithmicType,
01489 char *target, int32_t targetCapacity,
01490 const char *source, int32_t sourceLength,
01491 UErrorCode *pErrorCode);
01492
01500 U_CAPI int32_t U_EXPORT2
01501 ucnv_flushCache(void);
01502
01510 U_CAPI int32_t U_EXPORT2
01511 ucnv_countAvailable(void);
01512
01523 U_CAPI const char* U_EXPORT2
01524 ucnv_getAvailableName(int32_t n);
01525
01538 U_CAPI UEnumeration * U_EXPORT2
01539 ucnv_openAllNames(UErrorCode *pErrorCode);
01540
01551 U_CAPI uint16_t U_EXPORT2
01552 ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
01553
01566 U_CAPI const char * U_EXPORT2
01567 ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
01568
01582 U_CAPI void U_EXPORT2
01583 ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);
01584
01608 U_CAPI UEnumeration * U_EXPORT2
01609 ucnv_openStandardNames(const char *convName,
01610 const char *standard,
01611 UErrorCode *pErrorCode);
01612
01618 U_CAPI uint16_t U_EXPORT2
01619 ucnv_countStandards(void);
01620
01628 U_CAPI const char * U_EXPORT2
01629 ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
01630
01650 U_CAPI const char * U_EXPORT2
01651 ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
01652
01672 U_CAPI const char * U_EXPORT2
01673 ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);
01674
01685 U_CAPI const char * U_EXPORT2
01686 ucnv_getDefaultName(void);
01687
01696 U_CAPI void U_EXPORT2
01697 ucnv_setDefaultName(const char *name);
01698
01716 U_CAPI void U_EXPORT2
01717 ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);
01718
01727 U_CAPI UBool U_EXPORT2
01728 ucnv_isAmbiguous(const UConverter *cnv);
01729
01737 U_CAPI void U_EXPORT2
01738 ucnv_setFallback(UConverter *cnv, UBool usesFallback);
01739
01746 U_CAPI UBool U_EXPORT2
01747 ucnv_usesFallback(const UConverter *cnv);
01748
01806 U_CAPI const char* U_EXPORT2
01807 ucnv_detectUnicodeSignature(const char* source,
01808 int32_t sourceLength,
01809 int32_t *signatureLength,
01810 UErrorCode *pErrorCode);
01811
01812 #endif
01813
01814