ICU 52.1  52.1
ucnv.h
Go to the documentation of this file.
1 /*
2 **********************************************************************
3 * Copyright (C) 1999-2013, 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 
539 U_STABLE UConverter * U_EXPORT2
540 ucnv_safeClone(const UConverter *cnv,
541  void *stackBuffer,
542  int32_t *pBufferSize,
543  UErrorCode *status);
544 
545 #ifndef U_HIDE_DEPRECATED_API
546 
553 #define U_CNV_SAFECLONE_BUFFERSIZE 1024
554 
555 #endif /* U_HIDE_DEPRECATED_API */
556 
568 U_STABLE void U_EXPORT2
569 ucnv_close(UConverter * converter);
570 
571 #if U_SHOW_CPLUSPLUS_API
572 
574 
585 
587 
588 #endif
589 
607 U_STABLE void U_EXPORT2
608 ucnv_getSubstChars(const UConverter *converter,
609  char *subChars,
610  int8_t *len,
611  UErrorCode *err);
612 
632 U_STABLE void U_EXPORT2
633 ucnv_setSubstChars(UConverter *converter,
634  const char *subChars,
635  int8_t len,
636  UErrorCode *err);
637 
665 U_STABLE void U_EXPORT2
667  const UChar *s,
668  int32_t length,
669  UErrorCode *err);
670 
684 U_STABLE void U_EXPORT2
685 ucnv_getInvalidChars(const UConverter *converter,
686  char *errBytes,
687  int8_t *len,
688  UErrorCode *err);
689 
703 U_STABLE void U_EXPORT2
704 ucnv_getInvalidUChars(const UConverter *converter,
705  UChar *errUChars,
706  int8_t *len,
707  UErrorCode *err);
708 
716 U_STABLE void U_EXPORT2
717 ucnv_reset(UConverter *converter);
718 
727 U_STABLE void U_EXPORT2
728 ucnv_resetToUnicode(UConverter *converter);
729 
738 U_STABLE void U_EXPORT2
740 
789 U_STABLE int8_t U_EXPORT2
790 ucnv_getMaxCharSize(const UConverter *converter);
791 
811 #define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \
812  (((int32_t)(length)+10)*(int32_t)(maxCharSize))
813 
822 U_STABLE int8_t U_EXPORT2
823 ucnv_getMinCharSize(const UConverter *converter);
824 
839 U_STABLE int32_t U_EXPORT2
840 ucnv_getDisplayName(const UConverter *converter,
841  const char *displayLocale,
842  UChar *displayName,
843  int32_t displayNameCapacity,
844  UErrorCode *err);
845 
856 U_STABLE const char * U_EXPORT2
857 ucnv_getName(const UConverter *converter, UErrorCode *err);
858 
882 U_STABLE int32_t U_EXPORT2
883 ucnv_getCCSID(const UConverter *converter,
884  UErrorCode *err);
885 
897 ucnv_getPlatform(const UConverter *converter,
898  UErrorCode *err);
899 
908 U_STABLE UConverterType U_EXPORT2
909 ucnv_getType(const UConverter * converter);
910 
926 U_STABLE void U_EXPORT2
927 ucnv_getStarters(const UConverter* converter,
928  UBool starters[256],
929  UErrorCode* err);
930 
931 
937 typedef enum UConverterUnicodeSet {
945 
946 
992 U_STABLE void U_EXPORT2
993 ucnv_getUnicodeSet(const UConverter *cnv,
994  USet *setFillIn,
995  UConverterUnicodeSet whichSet,
996  UErrorCode *pErrorCode);
997 
1009 U_STABLE void U_EXPORT2
1010 ucnv_getToUCallBack (const UConverter * converter,
1011  UConverterToUCallback *action,
1012  const void **context);
1013 
1025 U_STABLE void U_EXPORT2
1026 ucnv_getFromUCallBack (const UConverter * converter,
1027  UConverterFromUCallback *action,
1028  const void **context);
1029 
1045 U_STABLE void U_EXPORT2
1046 ucnv_setToUCallBack (UConverter * converter,
1047  UConverterToUCallback newAction,
1048  const void* newContext,
1049  UConverterToUCallback *oldAction,
1050  const void** oldContext,
1051  UErrorCode * err);
1052 
1068 U_STABLE void U_EXPORT2
1069 ucnv_setFromUCallBack (UConverter * converter,
1070  UConverterFromUCallback newAction,
1071  const void *newContext,
1072  UConverterFromUCallback *oldAction,
1073  const void **oldContext,
1074  UErrorCode * err);
1075 
1134 U_STABLE void U_EXPORT2
1135 ucnv_fromUnicode (UConverter * converter,
1136  char **target,
1137  const char *targetLimit,
1138  const UChar ** source,
1139  const UChar * sourceLimit,
1140  int32_t* offsets,
1141  UBool flush,
1142  UErrorCode * err);
1143 
1203 U_STABLE void U_EXPORT2
1204 ucnv_toUnicode(UConverter *converter,
1205  UChar **target,
1206  const UChar *targetLimit,
1207  const char **source,
1208  const char *sourceLimit,
1209  int32_t *offsets,
1210  UBool flush,
1211  UErrorCode *err);
1212 
1240 U_STABLE int32_t U_EXPORT2
1242  char *dest, int32_t destCapacity,
1243  const UChar *src, int32_t srcLength,
1244  UErrorCode *pErrorCode);
1245 
1272 U_STABLE int32_t U_EXPORT2
1274  UChar *dest, int32_t destCapacity,
1275  const char *src, int32_t srcLength,
1276  UErrorCode *pErrorCode);
1277 
1348 U_STABLE UChar32 U_EXPORT2
1349 ucnv_getNextUChar(UConverter * converter,
1350  const char **source,
1351  const char * sourceLimit,
1352  UErrorCode * err);
1353 
1492 U_STABLE void U_EXPORT2
1493 ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
1494  char **target, const char *targetLimit,
1495  const char **source, const char *sourceLimit,
1496  UChar *pivotStart, UChar **pivotSource,
1497  UChar **pivotTarget, const UChar *pivotLimit,
1498  UBool reset, UBool flush,
1499  UErrorCode *pErrorCode);
1500 
1556 U_STABLE int32_t U_EXPORT2
1557 ucnv_convert(const char *toConverterName,
1558  const char *fromConverterName,
1559  char *target,
1560  int32_t targetCapacity,
1561  const char *source,
1562  int32_t sourceLength,
1563  UErrorCode *pErrorCode);
1564 
1610 U_STABLE int32_t U_EXPORT2
1611 ucnv_toAlgorithmic(UConverterType algorithmicType,
1612  UConverter *cnv,
1613  char *target, int32_t targetCapacity,
1614  const char *source, int32_t sourceLength,
1615  UErrorCode *pErrorCode);
1616 
1662 U_STABLE int32_t U_EXPORT2
1664  UConverterType algorithmicType,
1665  char *target, int32_t targetCapacity,
1666  const char *source, int32_t sourceLength,
1667  UErrorCode *pErrorCode);
1668 
1676 U_STABLE int32_t U_EXPORT2
1677 ucnv_flushCache(void);
1678 
1686 U_STABLE int32_t U_EXPORT2
1687 ucnv_countAvailable(void);
1688 
1699 U_STABLE const char* U_EXPORT2
1700 ucnv_getAvailableName(int32_t n);
1701 
1714 U_STABLE UEnumeration * U_EXPORT2
1715 ucnv_openAllNames(UErrorCode *pErrorCode);
1716 
1727 U_STABLE uint16_t U_EXPORT2
1728 ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
1729 
1742 U_STABLE const char * U_EXPORT2
1743 ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
1744 
1758 U_STABLE void U_EXPORT2
1759 ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);
1760 
1784 U_STABLE UEnumeration * U_EXPORT2
1785 ucnv_openStandardNames(const char *convName,
1786  const char *standard,
1787  UErrorCode *pErrorCode);
1788 
1794 U_STABLE uint16_t U_EXPORT2
1795 ucnv_countStandards(void);
1796 
1804 U_STABLE const char * U_EXPORT2
1805 ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
1806 
1826 U_STABLE const char * U_EXPORT2
1827 ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
1828 
1848 U_STABLE const char * U_EXPORT2
1849 ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);
1850 
1865 U_STABLE const char * U_EXPORT2
1866 ucnv_getDefaultName(void);
1867 
1868 #ifndef U_HIDE_SYSTEM_API
1869 
1885 U_STABLE void U_EXPORT2
1886 ucnv_setDefaultName(const char *name);
1887 #endif /* U_HIDE_SYSTEM_API */
1888 
1906 U_STABLE void U_EXPORT2
1907 ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);
1908 
1917 U_STABLE UBool U_EXPORT2
1918 ucnv_isAmbiguous(const UConverter *cnv);
1919 
1935 U_STABLE void U_EXPORT2
1936 ucnv_setFallback(UConverter *cnv, UBool usesFallback);
1937 
1947 U_STABLE UBool U_EXPORT2
1948 ucnv_usesFallback(const UConverter *cnv);
1949 
1979 U_STABLE const char* U_EXPORT2
1980 ucnv_detectUnicodeSignature(const char* source,
1981  int32_t sourceLength,
1982  int32_t *signatureLength,
1983  UErrorCode *pErrorCode);
1984 
1996 U_STABLE int32_t U_EXPORT2
1997 ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
1998 
2010 U_STABLE int32_t U_EXPORT2
2011 ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
2012 
2028 U_STABLE UBool U_EXPORT2
2029 ucnv_isFixedWidth(UConverter *cnv, UErrorCode *status);
2030 
2031 #endif
2032 
2033 #endif
2034 /*_UCNV*/