ICU 50.1.2  50.1.2
ucnv.h
Go to the documentation of this file.
1 /*
2 **********************************************************************
3 * Copyright (C) 1999-2012, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6  * ucnv.h:
7  * External APIs for the ICU's codeset conversion library
8  * Bertrand A. Damiba
9  *
10  * Modification History:
11  *
12  * Date Name Description
13  * 04/04/99 helena Fixed internal header inclusion.
14  * 05/11/00 helena Added setFallback and usesFallback APIs.
15  * 06/29/2000 helena Major rewrite of the callback APIs.
16  * 12/07/2000 srl Update of documentation
17  */
18 
47 #ifndef UCNV_H
48 #define UCNV_H
49 
50 #include "unicode/ucnv_err.h"
51 #include "unicode/uenum.h"
52 #include "unicode/localpointer.h"
53 
54 #ifndef __USET_H__
55 
65 struct USet;
67 typedef struct USet USet;
68 
69 #endif
70 
71 #if !UCONFIG_NO_CONVERSION
72 
74 
76 #define UCNV_MAX_CONVERTER_NAME_LENGTH 60
77 
78 #define UCNV_MAX_FULL_FILE_NAME_LENGTH (600+UCNV_MAX_CONVERTER_NAME_LENGTH)
79 
81 #define UCNV_SI 0x0F
82 
83 #define UCNV_SO 0x0E
84 
90 typedef enum {
94  UCNV_SBCS = 0,
96  UCNV_DBCS = 1,
98  UCNV_MBCS = 2,
115 
164 
165  /* Number of converter types for which we have conversion routines. */
166  UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES
168 
178 typedef enum {
179  UCNV_UNKNOWN = -1,
180  UCNV_IBM = 0
182 
198 typedef void (U_EXPORT2 *UConverterToUCallback) (
199  const void* context,
201  const char *codeUnits,
202  int32_t length,
204  UErrorCode *pErrorCode);
205 
221 typedef void (U_EXPORT2 *UConverterFromUCallback) (
222  const void* context,
224  const UChar* codeUnits,
225  int32_t length,
226  UChar32 codePoint,
228  UErrorCode *pErrorCode);
229 
231 
237 #define UCNV_OPTION_SEP_CHAR ','
238 
244 #define UCNV_OPTION_SEP_STRING ","
245 
251 #define UCNV_VALUE_SEP_CHAR '='
252 
258 #define UCNV_VALUE_SEP_STRING "="
259 
268 #define UCNV_LOCALE_OPTION_STRING ",locale="
269 
281 #define UCNV_VERSION_OPTION_STRING ",version="
282 
293 #define UCNV_SWAP_LFNL_OPTION_STRING ",swaplfnl"
294 
310 U_STABLE int U_EXPORT2
311 ucnv_compareNames(const char *name1, const char *name2);
312 
313 
364 U_STABLE UConverter* U_EXPORT2
365 ucnv_open(const char *converterName, UErrorCode *err);
366 
367 
394 U_STABLE UConverter* U_EXPORT2
395 ucnv_openU(const UChar *name,
396  UErrorCode *err);
397 
462 U_STABLE UConverter* U_EXPORT2
463 ucnv_openCCSID(int32_t codepage,
464  UConverterPlatform platform,
465  UErrorCode * err);
466 
497 U_STABLE UConverter* U_EXPORT2
498 ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err);
499 
537 U_STABLE UConverter * U_EXPORT2
538 ucnv_safeClone(const UConverter *cnv,
539  void *stackBuffer,
540  int32_t *pBufferSize,
541  UErrorCode *status);
542 
549 #define U_CNV_SAFECLONE_BUFFERSIZE 1024
550 
562 U_STABLE void U_EXPORT2
563 ucnv_close(UConverter * converter);
564 
565 #if U_SHOW_CPLUSPLUS_API
566 
568 
579 
581 
582 #endif
583 
601 U_STABLE void U_EXPORT2
602 ucnv_getSubstChars(const UConverter *converter,
603  char *subChars,
604  int8_t *len,
605  UErrorCode *err);
606 
626 U_STABLE void U_EXPORT2
627 ucnv_setSubstChars(UConverter *converter,
628  const char *subChars,
629  int8_t len,
630  UErrorCode *err);
631 
659 U_STABLE void U_EXPORT2
661  const UChar *s,
662  int32_t length,
663  UErrorCode *err);
664 
678 U_STABLE void U_EXPORT2
679 ucnv_getInvalidChars(const UConverter *converter,
680  char *errBytes,
681  int8_t *len,
682  UErrorCode *err);
683 
697 U_STABLE void U_EXPORT2
698 ucnv_getInvalidUChars(const UConverter *converter,
699  UChar *errUChars,
700  int8_t *len,
701  UErrorCode *err);
702 
710 U_STABLE void U_EXPORT2
711 ucnv_reset(UConverter *converter);
712 
721 U_STABLE void U_EXPORT2
722 ucnv_resetToUnicode(UConverter *converter);
723 
732 U_STABLE void U_EXPORT2
734 
783 U_STABLE int8_t U_EXPORT2
784 ucnv_getMaxCharSize(const UConverter *converter);
785 
805 #define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \
806  (((int32_t)(length)+10)*(int32_t)(maxCharSize))
807 
816 U_STABLE int8_t U_EXPORT2
817 ucnv_getMinCharSize(const UConverter *converter);
818 
833 U_STABLE int32_t U_EXPORT2
834 ucnv_getDisplayName(const UConverter *converter,
835  const char *displayLocale,
836  UChar *displayName,
837  int32_t displayNameCapacity,
838  UErrorCode *err);
839 
850 U_STABLE const char * U_EXPORT2
851 ucnv_getName(const UConverter *converter, UErrorCode *err);
852 
876 U_STABLE int32_t U_EXPORT2
877 ucnv_getCCSID(const UConverter *converter,
878  UErrorCode *err);
879 
891 ucnv_getPlatform(const UConverter *converter,
892  UErrorCode *err);
893 
902 U_STABLE UConverterType U_EXPORT2
903 ucnv_getType(const UConverter * converter);
904 
920 U_STABLE void U_EXPORT2
921 ucnv_getStarters(const UConverter* converter,
922  UBool starters[256],
923  UErrorCode* err);
924 
925 
931 typedef enum UConverterUnicodeSet {
939 
940 
986 U_STABLE void U_EXPORT2
987 ucnv_getUnicodeSet(const UConverter *cnv,
988  USet *setFillIn,
989  UConverterUnicodeSet whichSet,
990  UErrorCode *pErrorCode);
991 
1003 U_STABLE void U_EXPORT2
1004 ucnv_getToUCallBack (const UConverter * converter,
1005  UConverterToUCallback *action,
1006  const void **context);
1007 
1019 U_STABLE void U_EXPORT2
1020 ucnv_getFromUCallBack (const UConverter * converter,
1021  UConverterFromUCallback *action,
1022  const void **context);
1023 
1039 U_STABLE void U_EXPORT2
1040 ucnv_setToUCallBack (UConverter * converter,
1041  UConverterToUCallback newAction,
1042  const void* newContext,
1043  UConverterToUCallback *oldAction,
1044  const void** oldContext,
1045  UErrorCode * err);
1046 
1062 U_STABLE void U_EXPORT2
1063 ucnv_setFromUCallBack (UConverter * converter,
1064  UConverterFromUCallback newAction,
1065  const void *newContext,
1066  UConverterFromUCallback *oldAction,
1067  const void **oldContext,
1068  UErrorCode * err);
1069 
1128 U_STABLE void U_EXPORT2
1129 ucnv_fromUnicode (UConverter * converter,
1130  char **target,
1131  const char *targetLimit,
1132  const UChar ** source,
1133  const UChar * sourceLimit,
1134  int32_t* offsets,
1135  UBool flush,
1136  UErrorCode * err);
1137 
1197 U_STABLE void U_EXPORT2
1198 ucnv_toUnicode(UConverter *converter,
1199  UChar **target,
1200  const UChar *targetLimit,
1201  const char **source,
1202  const char *sourceLimit,
1203  int32_t *offsets,
1204  UBool flush,
1205  UErrorCode *err);
1206 
1234 U_STABLE int32_t U_EXPORT2
1236  char *dest, int32_t destCapacity,
1237  const UChar *src, int32_t srcLength,
1238  UErrorCode *pErrorCode);
1239 
1266 U_STABLE int32_t U_EXPORT2
1268  UChar *dest, int32_t destCapacity,
1269  const char *src, int32_t srcLength,
1270  UErrorCode *pErrorCode);
1271 
1342 U_STABLE UChar32 U_EXPORT2
1343 ucnv_getNextUChar(UConverter * converter,
1344  const char **source,
1345  const char * sourceLimit,
1346  UErrorCode * err);
1347 
1486 U_STABLE void U_EXPORT2
1487 ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
1488  char **target, const char *targetLimit,
1489  const char **source, const char *sourceLimit,
1490  UChar *pivotStart, UChar **pivotSource,
1491  UChar **pivotTarget, const UChar *pivotLimit,
1492  UBool reset, UBool flush,
1493  UErrorCode *pErrorCode);
1494 
1550 U_STABLE int32_t U_EXPORT2
1551 ucnv_convert(const char *toConverterName,
1552  const char *fromConverterName,
1553  char *target,
1554  int32_t targetCapacity,
1555  const char *source,
1556  int32_t sourceLength,
1557  UErrorCode *pErrorCode);
1558 
1604 U_STABLE int32_t U_EXPORT2
1605 ucnv_toAlgorithmic(UConverterType algorithmicType,
1606  UConverter *cnv,
1607  char *target, int32_t targetCapacity,
1608  const char *source, int32_t sourceLength,
1609  UErrorCode *pErrorCode);
1610 
1656 U_STABLE int32_t U_EXPORT2
1658  UConverterType algorithmicType,
1659  char *target, int32_t targetCapacity,
1660  const char *source, int32_t sourceLength,
1661  UErrorCode *pErrorCode);
1662 
1670 U_STABLE int32_t U_EXPORT2
1671 ucnv_flushCache(void);
1672 
1680 U_STABLE int32_t U_EXPORT2
1681 ucnv_countAvailable(void);
1682 
1693 U_STABLE const char* U_EXPORT2
1694 ucnv_getAvailableName(int32_t n);
1695 
1708 U_STABLE UEnumeration * U_EXPORT2
1709 ucnv_openAllNames(UErrorCode *pErrorCode);
1710 
1721 U_STABLE uint16_t U_EXPORT2
1722 ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
1723 
1736 U_STABLE const char * U_EXPORT2
1737 ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
1738 
1752 U_STABLE void U_EXPORT2
1753 ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);
1754 
1778 U_STABLE UEnumeration * U_EXPORT2
1779 ucnv_openStandardNames(const char *convName,
1780  const char *standard,
1781  UErrorCode *pErrorCode);
1782 
1788 U_STABLE uint16_t U_EXPORT2
1789 ucnv_countStandards(void);
1790 
1798 U_STABLE const char * U_EXPORT2
1799 ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
1800 
1820 U_STABLE const char * U_EXPORT2
1821 ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
1822 
1842 U_STABLE const char * U_EXPORT2
1843 ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);
1844 
1859 U_STABLE const char * U_EXPORT2
1860 ucnv_getDefaultName(void);
1861 
1862 #ifndef U_HIDE_SYSTEM_API
1863 
1879 U_STABLE void U_EXPORT2
1880 ucnv_setDefaultName(const char *name);
1881 #endif /* U_HIDE_SYSTEM_API */
1882 
1900 U_STABLE void U_EXPORT2
1901 ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);
1902 
1911 U_STABLE UBool U_EXPORT2
1912 ucnv_isAmbiguous(const UConverter *cnv);
1913 
1929 U_STABLE void U_EXPORT2
1930 ucnv_setFallback(UConverter *cnv, UBool usesFallback);
1931 
1941 U_STABLE UBool U_EXPORT2
1942 ucnv_usesFallback(const UConverter *cnv);
1943 
1973 U_STABLE const char* U_EXPORT2
1974 ucnv_detectUnicodeSignature(const char* source,
1975  int32_t sourceLength,
1976  int32_t *signatureLength,
1977  UErrorCode *pErrorCode);
1978 
1990 U_STABLE int32_t U_EXPORT2
1991 ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
1992 
2004 U_STABLE int32_t U_EXPORT2
2005 ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
2006 
2022 U_STABLE UBool U_EXPORT2
2023 ucnv_isFixedWidth(UConverter *cnv, UErrorCode *status);
2024 
2025 #endif
2026 
2027 #endif
2028 /*_UCNV*/