ICU 4.8 4.8
|
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 { 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 UCNV_COMPOUND_TEXT, 00128 00129 /* Number of converter types for which we have conversion routines. */ 00130 UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES 00131 00132 } UConverterType; 00133 00143 typedef enum { 00144 UCNV_UNKNOWN = -1, 00145 UCNV_IBM = 0 00146 } UConverterPlatform; 00147 00163 typedef void (U_EXPORT2 *UConverterToUCallback) ( 00164 const void* context, 00165 UConverterToUnicodeArgs *args, 00166 const char *codeUnits, 00167 int32_t length, 00168 UConverterCallbackReason reason, 00169 UErrorCode *pErrorCode); 00170 00186 typedef void (U_EXPORT2 *UConverterFromUCallback) ( 00187 const void* context, 00188 UConverterFromUnicodeArgs *args, 00189 const UChar* codeUnits, 00190 int32_t length, 00191 UChar32 codePoint, 00192 UConverterCallbackReason reason, 00193 UErrorCode *pErrorCode); 00194 00195 U_CDECL_END 00196 00202 #define UCNV_OPTION_SEP_CHAR ',' 00203 00209 #define UCNV_OPTION_SEP_STRING "," 00210 00216 #define UCNV_VALUE_SEP_CHAR '=' 00217 00223 #define UCNV_VALUE_SEP_STRING "=" 00224 00233 #define UCNV_LOCALE_OPTION_STRING ",locale=" 00234 00246 #define UCNV_VERSION_OPTION_STRING ",version=" 00247 00258 #define UCNV_SWAP_LFNL_OPTION_STRING ",swaplfnl" 00259 00275 U_STABLE int U_EXPORT2 00276 ucnv_compareNames(const char *name1, const char *name2); 00277 00278 00327 U_STABLE UConverter* U_EXPORT2 00328 ucnv_open(const char *converterName, UErrorCode *err); 00329 00330 00357 U_STABLE UConverter* U_EXPORT2 00358 ucnv_openU(const UChar *name, 00359 UErrorCode *err); 00360 00425 U_STABLE UConverter* U_EXPORT2 00426 ucnv_openCCSID(int32_t codepage, 00427 UConverterPlatform platform, 00428 UErrorCode * err); 00429 00460 U_STABLE UConverter* U_EXPORT2 00461 ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err); 00462 00500 U_STABLE UConverter * U_EXPORT2 00501 ucnv_safeClone(const UConverter *cnv, 00502 void *stackBuffer, 00503 int32_t *pBufferSize, 00504 UErrorCode *status); 00505 00512 #define U_CNV_SAFECLONE_BUFFERSIZE 1024 00513 00525 U_STABLE void U_EXPORT2 00526 ucnv_close(UConverter * converter); 00527 00528 #if U_SHOW_CPLUSPLUS_API 00529 00530 U_NAMESPACE_BEGIN 00531 00541 U_DEFINE_LOCAL_OPEN_POINTER(LocalUConverterPointer, UConverter, ucnv_close); 00542 00543 U_NAMESPACE_END 00544 00545 #endif 00546 00564 U_STABLE void U_EXPORT2 00565 ucnv_getSubstChars(const UConverter *converter, 00566 char *subChars, 00567 int8_t *len, 00568 UErrorCode *err); 00569 00589 U_STABLE void U_EXPORT2 00590 ucnv_setSubstChars(UConverter *converter, 00591 const char *subChars, 00592 int8_t len, 00593 UErrorCode *err); 00594 00622 U_STABLE void U_EXPORT2 00623 ucnv_setSubstString(UConverter *cnv, 00624 const UChar *s, 00625 int32_t length, 00626 UErrorCode *err); 00627 00641 U_STABLE void U_EXPORT2 00642 ucnv_getInvalidChars(const UConverter *converter, 00643 char *errBytes, 00644 int8_t *len, 00645 UErrorCode *err); 00646 00660 U_STABLE void U_EXPORT2 00661 ucnv_getInvalidUChars(const UConverter *converter, 00662 UChar *errUChars, 00663 int8_t *len, 00664 UErrorCode *err); 00665 00673 U_STABLE void U_EXPORT2 00674 ucnv_reset(UConverter *converter); 00675 00684 U_STABLE void U_EXPORT2 00685 ucnv_resetToUnicode(UConverter *converter); 00686 00695 U_STABLE void U_EXPORT2 00696 ucnv_resetFromUnicode(UConverter *converter); 00697 00746 U_STABLE int8_t U_EXPORT2 00747 ucnv_getMaxCharSize(const UConverter *converter); 00748 00768 #define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \ 00769 (((int32_t)(length)+10)*(int32_t)(maxCharSize)) 00770 00779 U_STABLE int8_t U_EXPORT2 00780 ucnv_getMinCharSize(const UConverter *converter); 00781 00796 U_STABLE int32_t U_EXPORT2 00797 ucnv_getDisplayName(const UConverter *converter, 00798 const char *displayLocale, 00799 UChar *displayName, 00800 int32_t displayNameCapacity, 00801 UErrorCode *err); 00802 00813 U_STABLE const char * U_EXPORT2 00814 ucnv_getName(const UConverter *converter, UErrorCode *err); 00815 00839 U_STABLE int32_t U_EXPORT2 00840 ucnv_getCCSID(const UConverter *converter, 00841 UErrorCode *err); 00842 00853 U_STABLE UConverterPlatform U_EXPORT2 00854 ucnv_getPlatform(const UConverter *converter, 00855 UErrorCode *err); 00856 00865 U_STABLE UConverterType U_EXPORT2 00866 ucnv_getType(const UConverter * converter); 00867 00883 U_STABLE void U_EXPORT2 00884 ucnv_getStarters(const UConverter* converter, 00885 UBool starters[256], 00886 UErrorCode* err); 00887 00888 00894 typedef enum UConverterUnicodeSet { 00896 UCNV_ROUNDTRIP_SET, 00898 UCNV_ROUNDTRIP_AND_FALLBACK_SET, 00900 UCNV_SET_COUNT 00901 } UConverterUnicodeSet; 00902 00903 00949 U_STABLE void U_EXPORT2 00950 ucnv_getUnicodeSet(const UConverter *cnv, 00951 USet *setFillIn, 00952 UConverterUnicodeSet whichSet, 00953 UErrorCode *pErrorCode); 00954 00966 U_STABLE void U_EXPORT2 00967 ucnv_getToUCallBack (const UConverter * converter, 00968 UConverterToUCallback *action, 00969 const void **context); 00970 00982 U_STABLE void U_EXPORT2 00983 ucnv_getFromUCallBack (const UConverter * converter, 00984 UConverterFromUCallback *action, 00985 const void **context); 00986 01002 U_STABLE void U_EXPORT2 01003 ucnv_setToUCallBack (UConverter * converter, 01004 UConverterToUCallback newAction, 01005 const void* newContext, 01006 UConverterToUCallback *oldAction, 01007 const void** oldContext, 01008 UErrorCode * err); 01009 01025 U_STABLE void U_EXPORT2 01026 ucnv_setFromUCallBack (UConverter * converter, 01027 UConverterFromUCallback newAction, 01028 const void *newContext, 01029 UConverterFromUCallback *oldAction, 01030 const void **oldContext, 01031 UErrorCode * err); 01032 01091 U_STABLE void U_EXPORT2 01092 ucnv_fromUnicode (UConverter * converter, 01093 char **target, 01094 const char *targetLimit, 01095 const UChar ** source, 01096 const UChar * sourceLimit, 01097 int32_t* offsets, 01098 UBool flush, 01099 UErrorCode * err); 01100 01160 U_STABLE void U_EXPORT2 01161 ucnv_toUnicode(UConverter *converter, 01162 UChar **target, 01163 const UChar *targetLimit, 01164 const char **source, 01165 const char *sourceLimit, 01166 int32_t *offsets, 01167 UBool flush, 01168 UErrorCode *err); 01169 01197 U_STABLE int32_t U_EXPORT2 01198 ucnv_fromUChars(UConverter *cnv, 01199 char *dest, int32_t destCapacity, 01200 const UChar *src, int32_t srcLength, 01201 UErrorCode *pErrorCode); 01202 01229 U_STABLE int32_t U_EXPORT2 01230 ucnv_toUChars(UConverter *cnv, 01231 UChar *dest, int32_t destCapacity, 01232 const char *src, int32_t srcLength, 01233 UErrorCode *pErrorCode); 01234 01305 U_STABLE UChar32 U_EXPORT2 01306 ucnv_getNextUChar(UConverter * converter, 01307 const char **source, 01308 const char * sourceLimit, 01309 UErrorCode * err); 01310 01449 U_STABLE void U_EXPORT2 01450 ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv, 01451 char **target, const char *targetLimit, 01452 const char **source, const char *sourceLimit, 01453 UChar *pivotStart, UChar **pivotSource, 01454 UChar **pivotTarget, const UChar *pivotLimit, 01455 UBool reset, UBool flush, 01456 UErrorCode *pErrorCode); 01457 01513 U_STABLE int32_t U_EXPORT2 01514 ucnv_convert(const char *toConverterName, 01515 const char *fromConverterName, 01516 char *target, 01517 int32_t targetCapacity, 01518 const char *source, 01519 int32_t sourceLength, 01520 UErrorCode *pErrorCode); 01521 01567 U_STABLE int32_t U_EXPORT2 01568 ucnv_toAlgorithmic(UConverterType algorithmicType, 01569 UConverter *cnv, 01570 char *target, int32_t targetCapacity, 01571 const char *source, int32_t sourceLength, 01572 UErrorCode *pErrorCode); 01573 01619 U_STABLE int32_t U_EXPORT2 01620 ucnv_fromAlgorithmic(UConverter *cnv, 01621 UConverterType algorithmicType, 01622 char *target, int32_t targetCapacity, 01623 const char *source, int32_t sourceLength, 01624 UErrorCode *pErrorCode); 01625 01633 U_STABLE int32_t U_EXPORT2 01634 ucnv_flushCache(void); 01635 01643 U_STABLE int32_t U_EXPORT2 01644 ucnv_countAvailable(void); 01645 01656 U_STABLE const char* U_EXPORT2 01657 ucnv_getAvailableName(int32_t n); 01658 01671 U_STABLE UEnumeration * U_EXPORT2 01672 ucnv_openAllNames(UErrorCode *pErrorCode); 01673 01684 U_STABLE uint16_t U_EXPORT2 01685 ucnv_countAliases(const char *alias, UErrorCode *pErrorCode); 01686 01699 U_STABLE const char * U_EXPORT2 01700 ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode); 01701 01715 U_STABLE void U_EXPORT2 01716 ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode); 01717 01741 U_STABLE UEnumeration * U_EXPORT2 01742 ucnv_openStandardNames(const char *convName, 01743 const char *standard, 01744 UErrorCode *pErrorCode); 01745 01751 U_STABLE uint16_t U_EXPORT2 01752 ucnv_countStandards(void); 01753 01761 U_STABLE const char * U_EXPORT2 01762 ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode); 01763 01783 U_STABLE const char * U_EXPORT2 01784 ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode); 01785 01805 U_STABLE const char * U_EXPORT2 01806 ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode); 01807 01822 U_STABLE const char * U_EXPORT2 01823 ucnv_getDefaultName(void); 01824 01841 U_STABLE void U_EXPORT2 01842 ucnv_setDefaultName(const char *name); 01843 01861 U_STABLE void U_EXPORT2 01862 ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen); 01863 01872 U_STABLE UBool U_EXPORT2 01873 ucnv_isAmbiguous(const UConverter *cnv); 01874 01890 U_STABLE void U_EXPORT2 01891 ucnv_setFallback(UConverter *cnv, UBool usesFallback); 01892 01902 U_STABLE UBool U_EXPORT2 01903 ucnv_usesFallback(const UConverter *cnv); 01904 01961 U_STABLE const char* U_EXPORT2 01962 ucnv_detectUnicodeSignature(const char* source, 01963 int32_t sourceLength, 01964 int32_t *signatureLength, 01965 UErrorCode *pErrorCode); 01966 01978 U_STABLE int32_t U_EXPORT2 01979 ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status); 01980 01992 U_STABLE int32_t U_EXPORT2 01993 ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status); 01994 02010 U_DRAFT UBool U_EXPORT2 02011 ucnv_isFixedWidth(UConverter *cnv, UErrorCode *status); 02012 02013 #endif 02014 02015 #endif 02016 /*_UCNV*/