sl@0: /* sl@0: ********************************************************************** sl@0: * Copyright (C) 1999-2005, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: ********************************************************************** sl@0: * ucnv.h: sl@0: * External APIs for the ICU's codeset conversion library sl@0: * Bertrand A. Damiba sl@0: * sl@0: * Modification History: sl@0: * sl@0: * Date Name Description sl@0: * 04/04/99 helena Fixed internal header inclusion. sl@0: * 05/11/00 helena Added setFallback and usesFallback APIs. sl@0: * 06/29/2000 helena Major rewrite of the callback APIs. sl@0: * 12/07/2000 srl Update of documentation sl@0: */ sl@0: sl@0: /** sl@0: * \file sl@0: * \brief C API: Character conversion sl@0: * sl@0: *

Character Conversion C API

sl@0: * sl@0: *

This API is used to convert codepage or character encoded data to and sl@0: * from UTF-16. You can open a converter with {@link ucnv_open() }. With that sl@0: * converter, you can get its properties, set options, convert your data and sl@0: * close the converter.

sl@0: * sl@0: *

Since many software programs recogize different converter names for sl@0: * different types of converters, there are other functions in this API to sl@0: * iterate over the converter aliases. The functions {@link ucnv_getAvailableName() }, sl@0: * {@link ucnv_getAlias() } and {@link ucnv_getStandardName() } are some of the sl@0: * more frequently used alias functions to get this information.

sl@0: * sl@0: *

When a converter encounters an illegal, irregular, invalid or unmappable character sl@0: * its default behavior is to use a substitution character to replace the sl@0: * bad byte sequence. This behavior can be changed by using {@link ucnv_setFromUCallBack() } sl@0: * or {@link ucnv_setToUCallBack() } on the converter. The header ucnv_err.h defines sl@0: * many other callback actions that can be used instead of a character substitution.

sl@0: * sl@0: *

More information about this API can be found in our sl@0: * User's sl@0: * Guide.

sl@0: */ sl@0: sl@0: #ifndef UCNV_H sl@0: #define UCNV_H sl@0: sl@0: #include "unicode/ucnv_err.h" sl@0: #include "unicode/uenum.h" sl@0: sl@0: #ifndef __USET_H__ sl@0: sl@0: /** sl@0: * USet is the C API type for Unicode sets. sl@0: * It is forward-declared here to avoid including the header file if related sl@0: * conversion APIs are not used. sl@0: * See unicode/uset.h sl@0: * sl@0: * @see ucnv_getUnicodeSet sl@0: * @stable ICU 2.6 sl@0: */ sl@0: struct USet; sl@0: /** @stable ICU 2.6 */ sl@0: typedef struct USet USet; sl@0: sl@0: #endif sl@0: sl@0: #if !UCONFIG_NO_CONVERSION sl@0: sl@0: U_CDECL_BEGIN sl@0: sl@0: /** Maximum length of a converter name including the terminating NULL @stable ICU 2.0 */ sl@0: #define UCNV_MAX_CONVERTER_NAME_LENGTH 60 sl@0: /** Maximum length of a converter name including path and terminating NULL @stable ICU 2.0 */ sl@0: #define UCNV_MAX_FULL_FILE_NAME_LENGTH (600+UCNV_MAX_CONVERTER_NAME_LENGTH) sl@0: sl@0: /** Shift in for EBDCDIC_STATEFUL and iso2022 states @stable ICU 2.0 */ sl@0: #define UCNV_SI 0x0F sl@0: /** Shift out for EBDCDIC_STATEFUL and iso2022 states @stable ICU 2.0 */ sl@0: #define UCNV_SO 0x0E sl@0: sl@0: /** sl@0: * Enum for specifying basic types of converters sl@0: * @see ucnv_getType sl@0: * @stable ICU 2.0 sl@0: */ sl@0: typedef enum { sl@0: UCNV_UNSUPPORTED_CONVERTER = -1, sl@0: UCNV_SBCS = 0, sl@0: UCNV_DBCS = 1, sl@0: UCNV_MBCS = 2, sl@0: UCNV_LATIN_1 = 3, sl@0: UCNV_UTF8 = 4, sl@0: UCNV_UTF16_BigEndian = 5, sl@0: UCNV_UTF16_LittleEndian = 6, sl@0: UCNV_UTF32_BigEndian = 7, sl@0: UCNV_UTF32_LittleEndian = 8, sl@0: UCNV_EBCDIC_STATEFUL = 9, sl@0: UCNV_ISO_2022 = 10, sl@0: sl@0: UCNV_LMBCS_1 = 11, sl@0: UCNV_LMBCS_2, sl@0: UCNV_LMBCS_3, sl@0: UCNV_LMBCS_4, sl@0: UCNV_LMBCS_5, sl@0: UCNV_LMBCS_6, sl@0: UCNV_LMBCS_8, sl@0: UCNV_LMBCS_11, sl@0: UCNV_LMBCS_16, sl@0: UCNV_LMBCS_17, sl@0: UCNV_LMBCS_18, sl@0: UCNV_LMBCS_19, sl@0: UCNV_LMBCS_LAST = UCNV_LMBCS_19, sl@0: UCNV_HZ, sl@0: UCNV_SCSU, sl@0: UCNV_ISCII, sl@0: UCNV_US_ASCII, sl@0: UCNV_UTF7, sl@0: UCNV_BOCU1, sl@0: UCNV_UTF16, sl@0: UCNV_UTF32, sl@0: UCNV_CESU8, sl@0: UCNV_IMAP_MAILBOX, sl@0: sl@0: /* Number of converter types for which we have conversion routines. */ sl@0: UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES sl@0: sl@0: } UConverterType; sl@0: sl@0: /** sl@0: * Enum for specifying which platform a converter ID refers to. sl@0: * The use of platform/CCSID is not recommended. See ucnv_openCCSID(). sl@0: * sl@0: * @see ucnv_getPlatform sl@0: * @see ucnv_openCCSID sl@0: * @see ucnv_getCCSID sl@0: * @stable ICU 2.0 sl@0: */ sl@0: typedef enum { sl@0: UCNV_UNKNOWN = -1, sl@0: UCNV_IBM = 0 sl@0: } UConverterPlatform; sl@0: sl@0: /** sl@0: * Function pointer for error callback in the codepage to unicode direction. sl@0: * Called when an error has occured in conversion to unicode, or on open/close of the callback (see reason). sl@0: * @param context Pointer to the callback's private data sl@0: * @param args Information about the conversion in progress sl@0: * @param codeUnits Points to 'length' bytes of the concerned codepage sequence sl@0: * @param length Size (in bytes) of the concerned codepage sequence sl@0: * @param reason Defines the reason the callback was invoked sl@0: * @param pErrorCode ICU error code in/out parameter. sl@0: * For converter callback functions, set to a conversion error sl@0: * before the call, and the callback may reset it to U_ZERO_ERROR. sl@0: * @see ucnv_setToUCallBack sl@0: * @see UConverterToUnicodeArgs sl@0: * @stable ICU 2.0 sl@0: */ sl@0: typedef void (U_EXPORT2 *UConverterToUCallback) ( sl@0: const void* context, sl@0: UConverterToUnicodeArgs *args, sl@0: const char *codeUnits, sl@0: int32_t length, sl@0: UConverterCallbackReason reason, sl@0: UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Function pointer for error callback in the unicode to codepage direction. sl@0: * Called when an error has occured in conversion from unicode, or on open/close of the callback (see reason). sl@0: * @param context Pointer to the callback's private data sl@0: * @param args Information about the conversion in progress sl@0: * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence sl@0: * @param length Size (in bytes) of the concerned codepage sequence sl@0: * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint. sl@0: * @param reason Defines the reason the callback was invoked sl@0: * @param pErrorCode ICU error code in/out parameter. sl@0: * For converter callback functions, set to a conversion error sl@0: * before the call, and the callback may reset it to U_ZERO_ERROR. sl@0: * @see ucnv_setFromUCallBack sl@0: * @stable ICU 2.0 sl@0: */ sl@0: typedef void (U_EXPORT2 *UConverterFromUCallback) ( sl@0: const void* context, sl@0: UConverterFromUnicodeArgs *args, sl@0: const UChar* codeUnits, sl@0: int32_t length, sl@0: UChar32 codePoint, sl@0: UConverterCallbackReason reason, sl@0: UErrorCode *pErrorCode); sl@0: sl@0: U_CDECL_END sl@0: sl@0: /** sl@0: * Character that separates converter names from options and options from each other. sl@0: * @see ucnv_open sl@0: * @stable ICU 2.0 sl@0: */ sl@0: #define UCNV_OPTION_SEP_CHAR ',' sl@0: sl@0: /** sl@0: * String version of UCNV_OPTION_SEP_CHAR. sl@0: * @see ucnv_open sl@0: * @stable ICU 2.0 sl@0: */ sl@0: #define UCNV_OPTION_SEP_STRING "," sl@0: sl@0: /** sl@0: * Character that separates a converter option from its value. sl@0: * @see ucnv_open sl@0: * @stable ICU 2.0 sl@0: */ sl@0: #define UCNV_VALUE_SEP_CHAR '=' sl@0: sl@0: /** sl@0: * String version of UCNV_VALUE_SEP_CHAR. sl@0: * @see ucnv_open sl@0: * @stable ICU 2.0 sl@0: */ sl@0: #define UCNV_VALUE_SEP_STRING "=" sl@0: sl@0: /** sl@0: * Converter option for specifying a locale. sl@0: * For example, ucnv_open("SCSU,locale=ja", &errorCode); sl@0: * See convrtrs.txt. sl@0: * sl@0: * @see ucnv_open sl@0: * @stable ICU 2.0 sl@0: */ sl@0: #define UCNV_LOCALE_OPTION_STRING ",locale=" sl@0: sl@0: /** sl@0: * Converter option for specifying a version selector (0..9) for some converters. sl@0: * For example, ucnv_open("UTF-7,version=1", &errorCode); sl@0: * See convrtrs.txt. sl@0: * sl@0: * @see ucnv_open sl@0: * @stable ICU 2.4 sl@0: */ sl@0: #define UCNV_VERSION_OPTION_STRING ",version=" sl@0: sl@0: /** sl@0: * Converter option for EBCDIC SBCS or mixed-SBCS/DBCS (stateful) codepages. sl@0: * Swaps Unicode mappings for EBCDIC LF and NL codes, as used on sl@0: * S/390 (z/OS) Unix System Services (Open Edition). sl@0: * For example, ucnv_open("ibm-1047,swaplfnl", &errorCode); sl@0: * See convrtrs.txt. sl@0: * sl@0: * @see ucnv_open sl@0: * @stable ICU 2.4 sl@0: */ sl@0: #define UCNV_SWAP_LFNL_OPTION_STRING ",swaplfnl" sl@0: sl@0: /** sl@0: * Do a fuzzy compare of a two converter/alias names. The comparison sl@0: * is case-insensitive. It also ignores the characters '-', '_', and sl@0: * ' ' (dash, underscore, and space). Thus the strings "UTF-8", sl@0: * "utf_8", and "Utf 8" are exactly equivalent. sl@0: * sl@0: * @param name1 a converter name or alias, zero-terminated sl@0: * @param name2 a converter name or alias, zero-terminated sl@0: * @return 0 if the names match, or a negative value if the name1 sl@0: * lexically precedes name2, or a positive value if the name1 sl@0: * lexically follows name2. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int U_EXPORT2 sl@0: ucnv_compareNames(const char *name1, const char *name2); sl@0: sl@0: sl@0: /** sl@0: * Creates a UConverter object with the names specified as a C string. sl@0: * The actual name will be resolved with the alias file sl@0: * using a case-insensitive string comparison that ignores sl@0: * the delimiters '-', '_', and ' ' (dash, underscore, and space). sl@0: * E.g., the names "UTF8", "utf-8", and "Utf 8" are all equivalent. sl@0: * If NULL is passed for the converter name, it will create one with the sl@0: * getDefaultName return value. sl@0: * sl@0: *

A converter name for ICU 1.5 and above may contain options sl@0: * like a locale specification to control the specific behavior of sl@0: * the newly instantiated converter. sl@0: * The meaning of the options depends on the particular converter. sl@0: * If an option is not defined for or recognized by a given converter, then it is ignored.

sl@0: * sl@0: *

Options are appended to the converter name string, with a sl@0: * UCNV_OPTION_SEP_CHAR between the name and the first option and sl@0: * also between adjacent options.

sl@0: * sl@0: *

If the alias is ambiguous, then the preferred converter is used sl@0: * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.

sl@0: * sl@0: *

The conversion behavior and names can vary between platforms. ICU may sl@0: * convert some characters differently from other platforms. Details on this topic sl@0: * are in the User's sl@0: * Guide.

sl@0: * sl@0: * @param converterName Name of the uconv table, may have options appended sl@0: * @param err outgoing error status U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR sl@0: * @return the created Unicode converter object, or NULL if an error occured sl@0: * @see ucnv_openU sl@0: * @see ucnv_openCCSID sl@0: * @see ucnv_close sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE UConverter* U_EXPORT2 sl@0: ucnv_open(const char *converterName, UErrorCode *err); sl@0: sl@0: sl@0: /** sl@0: * Creates a Unicode converter with the names specified as unicode string. sl@0: * The name should be limited to the ASCII-7 alphanumerics range. sl@0: * The actual name will be resolved with the alias file sl@0: * using a case-insensitive string comparison that ignores sl@0: * the delimiters '-', '_', and ' ' (dash, underscore, and space). sl@0: * E.g., the names "UTF8", "utf-8", and "Utf 8" are all equivalent. sl@0: * If NULL is passed for the converter name, it will create sl@0: * one with the ucnv_getDefaultName() return value. sl@0: * If the alias is ambiguous, then the preferred converter is used sl@0: * and the status is set to U_AMBIGUOUS_ALIAS_WARNING. sl@0: * @param name : name of the uconv table in a zero terminated sl@0: * Unicode string sl@0: * @param err outgoing error status U_MEMORY_ALLOCATION_ERROR, sl@0: * U_FILE_ACCESS_ERROR sl@0: * @return the created Unicode converter object, or NULL if an sl@0: * error occured sl@0: * @see ucnv_open sl@0: * @see ucnv_openCCSID sl@0: * @see ucnv_close sl@0: * @see ucnv_getDefaultName sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE UConverter* U_EXPORT2 sl@0: ucnv_openU(const UChar *name, sl@0: UErrorCode *err); sl@0: sl@0: /** sl@0: * Creates a UConverter object from a CCSID number and platform pair. sl@0: * Note that the usefulness of this function is limited to platforms with numeric sl@0: * encoding IDs. Only IBM and Microsoft platforms use numeric (16-bit) identifiers for sl@0: * encodings. sl@0: * sl@0: * In addition, IBM CCSIDs and Unicode conversion tables are not 1:1 related. sl@0: * For many IBM CCSIDs there are multiple (up to six) Unicode conversion tables, and sl@0: * for some Unicode conversion tables there are multiple CCSIDs. sl@0: * Some "alternate" Unicode conversion tables are provided by the sl@0: * IBM CDRA conversion table registry. sl@0: * The most prominent example of a systematic modification of conversion tables that is sl@0: * not provided in the form of conversion table files in the repository is sl@0: * that S/390 Unix System Services swaps the codes for Line Feed and New Line in all sl@0: * EBCDIC codepages, which requires such a swap in the Unicode conversion tables as well. sl@0: * sl@0: * Only IBM default conversion tables are accessible with ucnv_openCCSID(). sl@0: * ucnv_getCCSID() will return the same CCSID for all conversion tables that are associated sl@0: * with that CCSID. sl@0: * sl@0: * Currently, the only "platform" supported in the ICU converter API is UCNV_IBM. sl@0: * sl@0: * In summary, the use of CCSIDs and the associated API functions is not recommended. sl@0: * sl@0: * In order to open a converter with the default IBM CDRA Unicode conversion table, sl@0: * you can use this function or use the prefix "ibm-": sl@0: * \code sl@0: * char name[20]; sl@0: * sprintf(name, "ibm-%hu", ccsid); sl@0: * cnv=ucnv_open(name, &errorCode); sl@0: * \endcode sl@0: * sl@0: * In order to open a converter with the IBM S/390 Unix System Services variant sl@0: * of a Unicode/EBCDIC conversion table, sl@0: * you can use the prefix "ibm-" together with the option string UCNV_SWAP_LFNL_OPTION_STRING: sl@0: * \code sl@0: * char name[20]; sl@0: * sprintf(name, "ibm-%hu" UCNV_SWAP_LFNL_OPTION_STRING, ccsid); sl@0: * cnv=ucnv_open(name, &errorCode); sl@0: * \endcode sl@0: * sl@0: * In order to open a converter from a Microsoft codepage number, use the prefix "cp": sl@0: * \code sl@0: * char name[20]; sl@0: * sprintf(name, "cp%hu", codepageID); sl@0: * cnv=ucnv_open(name, &errorCode); sl@0: * \endcode sl@0: * sl@0: * If the alias is ambiguous, then the preferred converter is used sl@0: * and the status is set to U_AMBIGUOUS_ALIAS_WARNING. sl@0: * sl@0: * @param codepage codepage number to create sl@0: * @param platform the platform in which the codepage number exists sl@0: * @param err error status U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR sl@0: * @return the created Unicode converter object, or NULL if an error sl@0: * occured. sl@0: * @see ucnv_open sl@0: * @see ucnv_openU sl@0: * @see ucnv_close sl@0: * @see ucnv_getCCSID sl@0: * @see ucnv_getPlatform sl@0: * @see UConverterPlatform sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE UConverter* U_EXPORT2 sl@0: ucnv_openCCSID(int32_t codepage, sl@0: UConverterPlatform platform, sl@0: UErrorCode * err); sl@0: sl@0: /** sl@0: *

Creates a UConverter object specified from a packageName and a converterName.

sl@0: * sl@0: *

The packageName and converterName must point to an ICU udata object, as defined by sl@0: * udata_open( packageName, "cnv", converterName, err) or equivalent. sl@0: * Typically, packageName will refer to a (.dat) file, or to a package registered with sl@0: * udata_setAppData(). Using a full file or directory pathname for packageName is deprecated.

sl@0: * sl@0: *

The name will NOT be looked up in the alias mechanism, nor will the converter be sl@0: * stored in the converter cache or the alias table. The only way to open further converters sl@0: * is call this function multiple times, or use the ucnv_safeClone() function to clone a sl@0: * 'master' converter.

sl@0: * sl@0: *

A future version of ICU may add alias table lookups and/or caching sl@0: * to this function.

sl@0: * sl@0: *

Example Use: sl@0: * cnv = ucnv_openPackage("myapp", "myconverter", &err); sl@0: *

sl@0: * sl@0: * @param packageName name of the package (equivalent to 'path' in udata_open() call) sl@0: * @param converterName name of the data item to be used, without suffix. sl@0: * @param err outgoing error status U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR sl@0: * @return the created Unicode converter object, or NULL if an error occured sl@0: * @see udata_open sl@0: * @see ucnv_open sl@0: * @see ucnv_safeClone sl@0: * @see ucnv_close sl@0: * @stable ICU 2.2 sl@0: */ sl@0: U_STABLE UConverter* U_EXPORT2 sl@0: ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err); sl@0: sl@0: /** sl@0: * Thread safe converter cloning operation. sl@0: * For most efficient operation, pass in a stackBuffer (and a *pBufferSize) sl@0: * with at least U_CNV_SAFECLONE_BUFFERSIZE bytes of space. sl@0: * If the buffer size is sufficient, then the clone will use the stack buffer; sl@0: * otherwise, it will be allocated, and *pBufferSize will indicate sl@0: * the actual size. (This should not occur with U_CNV_SAFECLONE_BUFFERSIZE.) sl@0: * sl@0: * You must ucnv_close() the clone in any case. sl@0: * sl@0: * If *pBufferSize==0, (regardless of whether stackBuffer==NULL or not) sl@0: * then *pBufferSize will be changed to a sufficient size sl@0: * for cloning this converter, sl@0: * without actually cloning the converter ("pure pre-flighting"). sl@0: * sl@0: * If *pBufferSize is greater than zero but not large enough for a stack-based sl@0: * clone, then the converter is cloned using newly allocated memory sl@0: * and *pBufferSize is changed to the necessary size. sl@0: * sl@0: * If the converter clone fits into the stack buffer but the stack buffer is not sl@0: * sufficiently aligned for the clone, then the clone will use an sl@0: * adjusted pointer and use an accordingly smaller buffer size. sl@0: * sl@0: * @param cnv converter to be cloned sl@0: * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. sl@0: * If buffer is not large enough, new memory will be allocated. sl@0: * Clients can use the U_CNV_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations. sl@0: * @param pBufferSize pointer to size of allocated space. pBufferSize must not be NULL. sl@0: * @param status to indicate whether the operation went on smoothly or there were errors sl@0: * An informational status value, U_SAFECLONE_ALLOCATED_WARNING, sl@0: * is used if any allocations were necessary. sl@0: * However, it is better to check if *pBufferSize grew for checking for sl@0: * allocations because warning codes can be overridden by subsequent sl@0: * function calls. sl@0: * @return pointer to the new clone sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE UConverter * U_EXPORT2 sl@0: ucnv_safeClone(const UConverter *cnv, sl@0: void *stackBuffer, sl@0: int32_t *pBufferSize, sl@0: UErrorCode *status); sl@0: sl@0: /** sl@0: * \def U_CNV_SAFECLONE_BUFFERSIZE sl@0: * Definition of a buffer size that is designed to be large enough for sl@0: * converters to be cloned with ucnv_safeClone(). sl@0: * @stable ICU 2.0 sl@0: */ sl@0: #define U_CNV_SAFECLONE_BUFFERSIZE 1024 sl@0: sl@0: /** sl@0: * Deletes the unicode converter and releases resources associated sl@0: * with just this instance. sl@0: * Does not free up shared converter tables. sl@0: * sl@0: * @param converter the converter object to be deleted sl@0: * @see ucnv_open sl@0: * @see ucnv_openU sl@0: * @see ucnv_openCCSID sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_close(UConverter * converter); sl@0: sl@0: /** sl@0: * Fills in the output parameter, subChars, with the substitution characters sl@0: * as multiple bytes. sl@0: * sl@0: * @param converter the Unicode converter sl@0: * @param subChars the subsitution characters sl@0: * @param len on input the capacity of subChars, on output the number sl@0: * of bytes copied to it sl@0: * @param err the outgoing error status code. sl@0: * If the substitution character array is too small, an sl@0: * U_INDEX_OUTOFBOUNDS_ERROR will be returned. sl@0: * @see ucnv_setSubstChars sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_getSubstChars(const UConverter *converter, sl@0: char *subChars, sl@0: int8_t *len, sl@0: UErrorCode *err); sl@0: sl@0: /** sl@0: * Sets the substitution chars when converting from unicode to a codepage. The sl@0: * substitution is specified as a string of 1-4 bytes, and may contain sl@0: * NULL byte. sl@0: * @param converter the Unicode converter sl@0: * @param subChars the substitution character byte sequence we want set sl@0: * @param len the number of bytes in subChars sl@0: * @param err the error status code. U_INDEX_OUTOFBOUNDS_ERROR if sl@0: * len is bigger than the maximum number of bytes allowed in subchars sl@0: * @see ucnv_getSubstChars sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_setSubstChars(UConverter *converter, sl@0: const char *subChars, sl@0: int8_t len, sl@0: UErrorCode *err); sl@0: sl@0: /** sl@0: * Fills in the output parameter, errBytes, with the error characters from the sl@0: * last failing conversion. sl@0: * sl@0: * @param converter the Unicode converter sl@0: * @param errBytes the codepage bytes which were in error sl@0: * @param len on input the capacity of errBytes, on output the number of sl@0: * bytes which were copied to it sl@0: * @param err the error status code. sl@0: * If the substitution character array is too small, an sl@0: * U_INDEX_OUTOFBOUNDS_ERROR will be returned. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_getInvalidChars(const UConverter *converter, sl@0: char *errBytes, sl@0: int8_t *len, sl@0: UErrorCode *err); sl@0: sl@0: /** sl@0: * Fills in the output parameter, errChars, with the error characters from the sl@0: * last failing conversion. sl@0: * sl@0: * @param converter the Unicode converter sl@0: * @param errUChars the UChars which were in error sl@0: * @param len on input the capacity of errUChars, on output the number of sl@0: * UChars which were copied to it sl@0: * @param err the error status code. sl@0: * If the substitution character array is too small, an sl@0: * U_INDEX_OUTOFBOUNDS_ERROR will be returned. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_getInvalidUChars(const UConverter *converter, sl@0: UChar *errUChars, sl@0: int8_t *len, sl@0: UErrorCode *err); sl@0: sl@0: /** sl@0: * Resets the state of a converter to the default state. This is used sl@0: * in the case of an error, to restart a conversion from a known default state. sl@0: * It will also empty the internal output buffers. sl@0: * @param converter the Unicode converter sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_reset(UConverter *converter); sl@0: sl@0: /** sl@0: * Resets the to-Unicode part of a converter state to the default state. sl@0: * This is used in the case of an error to restart a conversion to sl@0: * Unicode to a known default state. It will also empty the internal sl@0: * output buffers used for the conversion to Unicode codepoints. sl@0: * @param converter the Unicode converter sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_resetToUnicode(UConverter *converter); sl@0: sl@0: /** sl@0: * Resets the from-Unicode part of a converter state to the default state. sl@0: * This is used in the case of an error to restart a conversion from sl@0: * Unicode to a known default state. It will also empty the internal output sl@0: * buffers used for the conversion from Unicode codepoints. sl@0: * @param converter the Unicode converter sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_resetFromUnicode(UConverter *converter); sl@0: sl@0: /** sl@0: * Returns the maximum number of bytes that are output per UChar in conversion sl@0: * from Unicode using this converter. sl@0: * The returned number can be used with UCNV_GET_MAX_BYTES_FOR_STRING sl@0: * to calculate the size of a target buffer for conversion from Unicode. sl@0: * sl@0: * Note: Before ICU 2.8, this function did not return reliable numbers for sl@0: * some stateful converters (EBCDIC_STATEFUL, ISO-2022) and LMBCS. sl@0: * sl@0: * This number may not be the same as the maximum number of bytes per sl@0: * "conversion unit". In other words, it may not be the intuitively expected sl@0: * number of bytes per character that would be published for a charset, sl@0: * and may not fulfill any other purpose than the allocation of an output sl@0: * buffer of guaranteed sufficient size for a given input length and converter. sl@0: * sl@0: * Examples for special cases that are taken into account: sl@0: * - Supplementary code points may convert to more bytes than BMP code points. sl@0: * This function returns bytes per UChar (UTF-16 code unit), not per sl@0: * Unicode code point, for efficient buffer allocation. sl@0: * - State-shifting output (SI/SO, escapes, etc.) from stateful converters. sl@0: * - When m input UChars are converted to n output bytes, then the maximum m/n sl@0: * is taken into account. sl@0: * sl@0: * The number returned here does not take into account sl@0: * (see UCNV_GET_MAX_BYTES_FOR_STRING): sl@0: * - callbacks which output more than one charset character sequence per call, sl@0: * like escape callbacks sl@0: * - initial and final non-character bytes that are output by some converters sl@0: * (automatic BOMs, initial escape sequence, final SI, etc.) sl@0: * sl@0: * Examples for returned values: sl@0: * - SBCS charsets: 1 sl@0: * - Shift-JIS: 2 sl@0: * - UTF-16: 2 (2 per BMP, 4 per surrogate _pair_, BOM not counted) sl@0: * - UTF-8: 3 (3 per BMP, 4 per surrogate _pair_) sl@0: * - EBCDIC_STATEFUL (EBCDIC mixed SBCS/DBCS): 3 (SO + DBCS) sl@0: * - ISO-2022: 3 (always outputs UTF-8) sl@0: * - ISO-2022-JP: 6 (4-byte escape sequences + DBCS) sl@0: * - ISO-2022-CN: 8 (4-byte designator sequences + 2-byte SS2/SS3 + DBCS) sl@0: * sl@0: * @param converter The Unicode converter. sl@0: * @return The maximum number of bytes per UChar that are output by ucnv_fromUnicode(), sl@0: * to be used together with UCNV_GET_MAX_BYTES_FOR_STRING for buffer allocation. sl@0: * sl@0: * @see UCNV_GET_MAX_BYTES_FOR_STRING sl@0: * @see ucnv_getMinCharSize sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int8_t U_EXPORT2 sl@0: ucnv_getMaxCharSize(const UConverter *converter); sl@0: sl@0: #ifndef U_HIDE_DRAFT_API sl@0: sl@0: /** sl@0: * Calculates the size of a buffer for conversion from Unicode to a charset. sl@0: * The calculated size is guaranteed to be sufficient for this conversion. sl@0: * sl@0: * It takes into account initial and final non-character bytes that are output sl@0: * by some converters. sl@0: * It does not take into account callbacks which output more than one charset sl@0: * character sequence per call, like escape callbacks. sl@0: * The default (substitution) callback only outputs one charset character sequence. sl@0: * sl@0: * @param length Number of UChars to be converted. sl@0: * @param maxCharSize Return value from ucnv_getMaxCharSize() for the converter sl@0: * that will be used. sl@0: * @return Size of a buffer that will be large enough to hold the output bytes of sl@0: * converting length UChars with the converter that returned the maxCharSize. sl@0: * sl@0: * @see ucnv_getMaxCharSize sl@0: * @stable ICU 2.8 sl@0: */ sl@0: #define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \ sl@0: (((int32_t)(length)+10)*(int32_t)(maxCharSize)) sl@0: sl@0: #endif /*U_HIDE_DRAFT_API*/ sl@0: sl@0: /** sl@0: * Returns the minimum byte length for characters in this codepage. sl@0: * This is usually either 1 or 2. sl@0: * @param converter the Unicode converter sl@0: * @return the minimum number of bytes allowed by this particular converter sl@0: * @see ucnv_getMaxCharSize sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int8_t U_EXPORT2 sl@0: ucnv_getMinCharSize(const UConverter *converter); sl@0: sl@0: /** sl@0: * Returns the display name of the converter passed in based on the Locale sl@0: * passed in. If the locale contains no display name, the internal ASCII sl@0: * name will be filled in. sl@0: * sl@0: * @param converter the Unicode converter. sl@0: * @param displayLocale is the specific Locale we want to localised for sl@0: * @param displayName user provided buffer to be filled in sl@0: * @param displayNameCapacity size of displayName Buffer sl@0: * @param err error status code sl@0: * @return displayNameLength number of UChar needed in displayName sl@0: * @see ucnv_getName sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: ucnv_getDisplayName(const UConverter *converter, sl@0: const char *displayLocale, sl@0: UChar *displayName, sl@0: int32_t displayNameCapacity, sl@0: UErrorCode *err); sl@0: sl@0: /** sl@0: * Gets the internal, canonical name of the converter (zero-terminated). sl@0: * The lifetime of the returned string will be that of the converter sl@0: * passed to this function. sl@0: * @param converter the Unicode converter sl@0: * @param err UErrorCode status sl@0: * @return the internal name of the converter sl@0: * @see ucnv_getDisplayName sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE const char * U_EXPORT2 sl@0: ucnv_getName(const UConverter *converter, UErrorCode *err); sl@0: sl@0: /** sl@0: * Gets a codepage number associated with the converter. This is not guaranteed sl@0: * to be the one used to create the converter. Some converters do not represent sl@0: * platform registered codepages and return zero for the codepage number. sl@0: * The error code fill-in parameter indicates if the codepage number sl@0: * is available. sl@0: * Does not check if the converter is NULL or if converter's data sl@0: * table is NULL. sl@0: * sl@0: * Important: The use of CCSIDs is not recommended because it is limited sl@0: * to only two platforms in principle and only one (UCNV_IBM) in the current sl@0: * ICU converter API. sl@0: * Also, CCSIDs are insufficient to identify IBM Unicode conversion tables precisely. sl@0: * For more details see ucnv_openCCSID(). sl@0: * sl@0: * @param converter the Unicode converter sl@0: * @param err the error status code. sl@0: * @return If any error occurrs, -1 will be returned otherwise, the codepage number sl@0: * will be returned sl@0: * @see ucnv_openCCSID sl@0: * @see ucnv_getPlatform sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: ucnv_getCCSID(const UConverter *converter, sl@0: UErrorCode *err); sl@0: sl@0: /** sl@0: * Gets a codepage platform associated with the converter. Currently, sl@0: * only UCNV_IBM will be returned. sl@0: * Does not test if the converter is NULL or if converter's data sl@0: * table is NULL. sl@0: * @param converter the Unicode converter sl@0: * @param err the error status code. sl@0: * @return The codepage platform sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE UConverterPlatform U_EXPORT2 sl@0: ucnv_getPlatform(const UConverter *converter, sl@0: UErrorCode *err); sl@0: sl@0: /** sl@0: * Gets the type of the converter sl@0: * e.g. SBCS, MBCS, DBCS, UTF8, UTF16_BE, UTF16_LE, ISO_2022, sl@0: * EBCDIC_STATEFUL, LATIN_1 sl@0: * @param converter a valid, opened converter sl@0: * @return the type of the converter sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE UConverterType U_EXPORT2 sl@0: ucnv_getType(const UConverter * converter); sl@0: sl@0: /** sl@0: * Gets the "starter" (lead) bytes for converters of type MBCS. sl@0: * Will fill in an U_ILLEGAL_ARGUMENT_ERROR if converter passed in sl@0: * is not MBCS. Fills in an array of type UBool, with the value of the byte sl@0: * as offset to the array. For example, if (starters[0x20] == TRUE) at return, sl@0: * it means that the byte 0x20 is a starter byte in this converter. sl@0: * Context pointers are always owned by the caller. sl@0: * sl@0: * @param converter a valid, opened converter of type MBCS sl@0: * @param starters an array of size 256 to be filled in sl@0: * @param err error status, U_ILLEGAL_ARGUMENT_ERROR if the sl@0: * converter is not a type which can return starters. sl@0: * @see ucnv_getType sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_getStarters(const UConverter* converter, sl@0: UBool starters[256], sl@0: UErrorCode* err); sl@0: sl@0: sl@0: /** sl@0: * Selectors for Unicode sets that can be returned by ucnv_getUnicodeSet(). sl@0: * @see ucnv_getUnicodeSet sl@0: * @stable ICU 2.6 sl@0: */ sl@0: typedef enum UConverterUnicodeSet { sl@0: /** Select the set of roundtrippable Unicode code points. @stable ICU 2.6 */ sl@0: UCNV_ROUNDTRIP_SET, sl@0: /** Number of UConverterUnicodeSet selectors. @stable ICU 2.6 */ sl@0: UCNV_SET_COUNT sl@0: } UConverterUnicodeSet; sl@0: sl@0: sl@0: /** sl@0: * Returns the set of Unicode code points that can be converted by an ICU converter. sl@0: * sl@0: * The current implementation returns only one kind of set (UCNV_ROUNDTRIP_SET): sl@0: * The set of all Unicode code points that can be roundtrip-converted sl@0: * (converted without any data loss) with the converter. sl@0: * This set will not include code points that have fallback mappings sl@0: * or are only the result of reverse fallback mappings. sl@0: * See UTR #22 "Character Mapping Markup Language" sl@0: * at http://www.unicode.org/reports/tr22/ sl@0: * sl@0: * This is useful for example for sl@0: * - checking that a string or document can be roundtrip-converted with a converter, sl@0: * without/before actually performing the conversion sl@0: * - testing if a converter can be used for text for typical text for a certain locale, sl@0: * by comparing its roundtrip set with the set of ExemplarCharacters from sl@0: * ICU's locale data or other sources sl@0: * sl@0: * In the future, there may be more UConverterUnicodeSet choices to select sl@0: * sets with different properties. sl@0: * sl@0: * @param cnv The converter for which a set is requested. sl@0: * @param setFillIn A valid USet *. It will be cleared by this function before sl@0: * the converter's specific set is filled into the USet. sl@0: * @param whichSet A UConverterUnicodeSet selector; sl@0: * currently UCNV_ROUNDTRIP_SET is the only supported value. sl@0: * @param pErrorCode ICU error code in/out parameter. sl@0: * Must fulfill U_SUCCESS before the function call. sl@0: * sl@0: * @see UConverterUnicodeSet sl@0: * @see uset_open sl@0: * @see uset_close sl@0: * @stable ICU 2.6 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_getUnicodeSet(const UConverter *cnv, sl@0: USet *setFillIn, sl@0: UConverterUnicodeSet whichSet, sl@0: UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Gets the current calback function used by the converter when an illegal sl@0: * or invalid codepage sequence is found. sl@0: * Context pointers are always owned by the caller. sl@0: * sl@0: * @param converter the unicode converter sl@0: * @param action fillin: returns the callback function pointer sl@0: * @param context fillin: returns the callback's private void* context sl@0: * @see ucnv_setToUCallBack sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_getToUCallBack (const UConverter * converter, sl@0: UConverterToUCallback *action, sl@0: const void **context); sl@0: sl@0: /** sl@0: * Gets the current callback function used by the converter when illegal sl@0: * or invalid Unicode sequence is found. sl@0: * Context pointers are always owned by the caller. sl@0: * sl@0: * @param converter the unicode converter sl@0: * @param action fillin: returns the callback function pointer sl@0: * @param context fillin: returns the callback's private void* context sl@0: * @see ucnv_setFromUCallBack sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_getFromUCallBack (const UConverter * converter, sl@0: UConverterFromUCallback *action, sl@0: const void **context); sl@0: sl@0: /** sl@0: * Changes the callback function used by the converter when sl@0: * an illegal or invalid sequence is found. sl@0: * Context pointers are always owned by the caller. sl@0: * Predefined actions and contexts can be found in the ucnv_err.h header. sl@0: * sl@0: * @param converter the unicode converter sl@0: * @param newAction the new callback function sl@0: * @param newContext the new toUnicode callback context pointer. This can be NULL. sl@0: * @param oldAction fillin: returns the old callback function pointer. This can be NULL. sl@0: * @param oldContext fillin: returns the old callback's private void* context. This can be NULL. sl@0: * @param err The error code status sl@0: * @see ucnv_getToUCallBack sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_setToUCallBack (UConverter * converter, sl@0: UConverterToUCallback newAction, sl@0: const void* newContext, sl@0: UConverterToUCallback *oldAction, sl@0: const void** oldContext, sl@0: UErrorCode * err); sl@0: sl@0: /** sl@0: * Changes the current callback function used by the converter when sl@0: * an illegal or invalid sequence is found. sl@0: * Context pointers are always owned by the caller. sl@0: * Predefined actions and contexts can be found in the ucnv_err.h header. sl@0: * sl@0: * @param converter the unicode converter sl@0: * @param newAction the new callback function sl@0: * @param newContext the new fromUnicode callback context pointer. This can be NULL. sl@0: * @param oldAction fillin: returns the old callback function pointer. This can be NULL. sl@0: * @param oldContext fillin: returns the old callback's private void* context. This can be NULL. sl@0: * @param err The error code status sl@0: * @see ucnv_getFromUCallBack sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_setFromUCallBack (UConverter * converter, sl@0: UConverterFromUCallback newAction, sl@0: const void *newContext, sl@0: UConverterFromUCallback *oldAction, sl@0: const void **oldContext, sl@0: UErrorCode * err); sl@0: sl@0: /** sl@0: * Converts an array of unicode characters to an array of codepage sl@0: * characters. This function is optimized for converting a continuous sl@0: * stream of data in buffer-sized chunks, where the entire source and sl@0: * target does not fit in available buffers. sl@0: * sl@0: * The source pointer is an in/out parameter. It starts out pointing where the sl@0: * conversion is to begin, and ends up pointing after the last UChar consumed. sl@0: * sl@0: * Target similarly starts out pointer at the first available byte in the output sl@0: * buffer, and ends up pointing after the last byte written to the output. sl@0: * sl@0: * The converter always attempts to consume the entire source buffer, unless sl@0: * (1.) the target buffer is full, or (2.) a failing error is returned from the sl@0: * current callback function. When a successful error status has been sl@0: * returned, it means that all of the source buffer has been sl@0: * consumed. At that point, the caller should reset the source and sl@0: * sourceLimit pointers to point to the next chunk. sl@0: * sl@0: * At the end of the stream (flush==TRUE), the input is completely consumed sl@0: * when *source==sourceLimit and no error code is set. sl@0: * The converter object is then automatically reset by this function. sl@0: * (This means that a converter need not be reset explicitly between data sl@0: * streams if it finishes the previous stream without errors.) sl@0: * sl@0: * This is a stateful conversion. Additionally, even when all source data has sl@0: * been consumed, some data may be in the converters' internal state. sl@0: * Call this function repeatedly, updating the target pointers with sl@0: * the next empty chunk of target in case of a sl@0: * U_BUFFER_OVERFLOW_ERROR, and updating the source pointers sl@0: * with the next chunk of source when a successful error status is sl@0: * returned, until there are no more chunks of source data. sl@0: * @param converter the Unicode converter sl@0: * @param target I/O parameter. Input : Points to the beginning of the buffer to copy sl@0: * codepage characters to. Output : points to after the last codepage character copied sl@0: * to target. sl@0: * @param targetLimit the pointer just after last of the target buffer sl@0: * @param source I/O parameter, pointer to pointer to the source Unicode character buffer. sl@0: * @param sourceLimit the pointer just after the last of the source buffer sl@0: * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number sl@0: * of allocated cells as target. Will fill in offsets from target to source pointer sl@0: * e.g: offsets[3] is equal to 6, it means that the target[3] was a result of transcoding source[6] sl@0: * For output data carried across calls, and other data without a specific source character sl@0: * (such as from escape sequences or callbacks) -1 will be placed for offsets. sl@0: * @param flush set to TRUE if the current source buffer is the last available sl@0: * chunk of the source, FALSE otherwise. Note that if a failing status is returned, sl@0: * this function may have to be called multiple times with flush set to TRUE until sl@0: * the source buffer is consumed. sl@0: * @param err the error status. U_ILLEGAL_ARGUMENT_ERROR will be set if the sl@0: * converter is NULL. sl@0: * U_BUFFER_OVERFLOW_ERROR will be set if the target is full and there is sl@0: * still data to be written to the target. sl@0: * @see ucnv_fromUChars sl@0: * @see ucnv_convert sl@0: * @see ucnv_getMinCharSize sl@0: * @see ucnv_setToUCallBack sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_fromUnicode (UConverter * converter, sl@0: char **target, sl@0: const char *targetLimit, sl@0: const UChar ** source, sl@0: const UChar * sourceLimit, sl@0: int32_t* offsets, sl@0: UBool flush, sl@0: UErrorCode * err); sl@0: sl@0: /** sl@0: * Converts a buffer of codepage bytes into an array of unicode UChars sl@0: * characters. This function is optimized for converting a continuous sl@0: * stream of data in buffer-sized chunks, where the entire source and sl@0: * target does not fit in available buffers. sl@0: * sl@0: * The source pointer is an in/out parameter. It starts out pointing where the sl@0: * conversion is to begin, and ends up pointing after the last byte of source consumed. sl@0: * sl@0: * Target similarly starts out pointer at the first available UChar in the output sl@0: * buffer, and ends up pointing after the last UChar written to the output. sl@0: * It does NOT necessarily keep UChar sequences together. sl@0: * sl@0: * The converter always attempts to consume the entire source buffer, unless sl@0: * (1.) the target buffer is full, or (2.) a failing error is returned from the sl@0: * current callback function. When a successful error status has been sl@0: * returned, it means that all of the source buffer has been sl@0: * consumed. At that point, the caller should reset the source and sl@0: * sourceLimit pointers to point to the next chunk. sl@0: * sl@0: * At the end of the stream (flush==TRUE), the input is completely consumed sl@0: * when *source==sourceLimit and no error code is set sl@0: * The converter object is then automatically reset by this function. sl@0: * (This means that a converter need not be reset explicitly between data sl@0: * streams if it finishes the previous stream without errors.) sl@0: * sl@0: * This is a stateful conversion. Additionally, even when all source data has sl@0: * been consumed, some data may be in the converters' internal state. sl@0: * Call this function repeatedly, updating the target pointers with sl@0: * the next empty chunk of target in case of a sl@0: * U_BUFFER_OVERFLOW_ERROR, and updating the source pointers sl@0: * with the next chunk of source when a successful error status is sl@0: * returned, until there are no more chunks of source data. sl@0: * @param converter the Unicode converter sl@0: * @param target I/O parameter. Input : Points to the beginning of the buffer to copy sl@0: * UChars into. Output : points to after the last UChar copied. sl@0: * @param targetLimit the pointer just after the end of the target buffer sl@0: * @param source I/O parameter, pointer to pointer to the source codepage buffer. sl@0: * @param sourceLimit the pointer to the byte after the end of the source buffer sl@0: * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number sl@0: * of allocated cells as target. Will fill in offsets from target to source pointer sl@0: * e.g: offsets[3] is equal to 6, it means that the target[3] was a result of transcoding source[6] sl@0: * For output data carried across calls, and other data without a specific source character sl@0: * (such as from escape sequences or callbacks) -1 will be placed for offsets. sl@0: * @param flush set to TRUE if the current source buffer is the last available sl@0: * chunk of the source, FALSE otherwise. Note that if a failing status is returned, sl@0: * this function may have to be called multiple times with flush set to TRUE until sl@0: * the source buffer is consumed. sl@0: * @param err the error status. U_ILLEGAL_ARGUMENT_ERROR will be set if the sl@0: * converter is NULL. sl@0: * U_BUFFER_OVERFLOW_ERROR will be set if the target is full and there is sl@0: * still data to be written to the target. sl@0: * @see ucnv_fromUChars sl@0: * @see ucnv_convert sl@0: * @see ucnv_getMinCharSize sl@0: * @see ucnv_setFromUCallBack sl@0: * @see ucnv_getNextUChar sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_toUnicode(UConverter *converter, sl@0: UChar **target, sl@0: const UChar *targetLimit, sl@0: const char **source, sl@0: const char *sourceLimit, sl@0: int32_t *offsets, sl@0: UBool flush, sl@0: UErrorCode *err); sl@0: sl@0: /** sl@0: * Convert the Unicode string into a codepage string using an existing UConverter. sl@0: * The output string is NUL-terminated if possible. sl@0: * sl@0: * This function is a more convenient but less powerful version of ucnv_fromUnicode(). sl@0: * It is only useful for whole strings, not for streaming conversion. sl@0: * sl@0: * The maximum output buffer capacity required (barring output from callbacks) will be sl@0: * UCNV_GET_MAX_BYTES_FOR_STRING(srcLength, ucnv_getMaxCharSize(cnv)). sl@0: * sl@0: * @param cnv the converter object to be used (ucnv_resetFromUnicode() will be called) sl@0: * @param src the input Unicode string sl@0: * @param srcLength the input string length, or -1 if NUL-terminated sl@0: * @param dest destination string buffer, can be NULL if destCapacity==0 sl@0: * @param destCapacity the number of chars available at dest sl@0: * @param pErrorCode normal ICU error code; sl@0: * common error codes that may be set by this function include sl@0: * U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING, sl@0: * U_ILLEGAL_ARGUMENT_ERROR, and conversion errors sl@0: * @return the length of the output string, not counting the terminating NUL; sl@0: * if the length is greater than destCapacity, then the string will not fit sl@0: * and a buffer of the indicated length would need to be passed in sl@0: * @see ucnv_fromUnicode sl@0: * @see ucnv_convert sl@0: * @see UCNV_GET_MAX_BYTES_FOR_STRING sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: ucnv_fromUChars(UConverter *cnv, sl@0: char *dest, int32_t destCapacity, sl@0: const UChar *src, int32_t srcLength, sl@0: UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Convert the codepage string into a Unicode string using an existing UConverter. sl@0: * The output string is NUL-terminated if possible. sl@0: * sl@0: * This function is a more convenient but less powerful version of ucnv_toUnicode(). sl@0: * It is only useful for whole strings, not for streaming conversion. sl@0: * sl@0: * The maximum output buffer capacity required (barring output from callbacks) will be sl@0: * 2*srcLength (each char may be converted into a surrogate pair). sl@0: * sl@0: * @param cnv the converter object to be used (ucnv_resetToUnicode() will be called) sl@0: * @param src the input codepage string sl@0: * @param srcLength the input string length, or -1 if NUL-terminated sl@0: * @param dest destination string buffer, can be NULL if destCapacity==0 sl@0: * @param destCapacity the number of UChars available at dest sl@0: * @param pErrorCode normal ICU error code; sl@0: * common error codes that may be set by this function include sl@0: * U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING, sl@0: * U_ILLEGAL_ARGUMENT_ERROR, and conversion errors sl@0: * @return the length of the output string, not counting the terminating NUL; sl@0: * if the length is greater than destCapacity, then the string will not fit sl@0: * and a buffer of the indicated length would need to be passed in sl@0: * @see ucnv_toUnicode sl@0: * @see ucnv_convert sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE int32_t U_EXPORT2 sl@0: ucnv_toUChars(UConverter *cnv, sl@0: UChar *dest, int32_t destCapacity, sl@0: const char *src, int32_t srcLength, sl@0: UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Convert a codepage buffer into Unicode one character at a time. sl@0: * The input is completely consumed when the U_INDEX_OUTOFBOUNDS_ERROR is set. sl@0: * sl@0: * Advantage compared to ucnv_toUnicode() or ucnv_toUChars(): sl@0: * - Faster for small amounts of data, for most converters, e.g., sl@0: * US-ASCII, ISO-8859-1, UTF-8/16/32, and most "normal" charsets. sl@0: * (For complex converters, e.g., SCSU, UTF-7 and ISO 2022 variants, sl@0: * it uses ucnv_toUnicode() internally.) sl@0: * - Convenient. sl@0: * sl@0: * Limitations compared to ucnv_toUnicode(): sl@0: * - Always assumes flush=TRUE. sl@0: * This makes ucnv_getNextUChar() unsuitable for "streaming" conversion, sl@0: * that is, for where the input is supplied in multiple buffers, sl@0: * because ucnv_getNextUChar() will assume the end of the input at the end sl@0: * of the first buffer. sl@0: * - Does not provide offset output. sl@0: * sl@0: * It is possible to "mix" ucnv_getNextUChar() and ucnv_toUnicode() because sl@0: * ucnv_getNextUChar() uses the current state of the converter sl@0: * (unlike ucnv_toUChars() which always resets first). sl@0: * However, if ucnv_getNextUChar() is called after ucnv_toUnicode() sl@0: * stopped in the middle of a character sequence (with flush=FALSE), sl@0: * then ucnv_getNextUChar() will always use the slower ucnv_toUnicode() sl@0: * internally until the next character boundary. sl@0: * (This is new in ICU 2.6. In earlier releases, ucnv_getNextUChar() had to sl@0: * start at a character boundary.) sl@0: * sl@0: * Instead of using ucnv_getNextUChar(), it is recommended sl@0: * to convert using ucnv_toUnicode() or ucnv_toUChars() sl@0: * and then iterate over the text using U16_NEXT() or a UCharIterator (uiter.h) sl@0: * or a C++ CharacterIterator or similar. sl@0: * This allows streaming conversion and offset output, for example. sl@0: * sl@0: *

Handling of surrogate pairs and supplementary-plane code points:
sl@0: * There are two different kinds of codepages that provide mappings for surrogate characters: sl@0: *

sl@0: * sl@0: * @param converter an open UConverter sl@0: * @param source the address of a pointer to the codepage buffer, will be sl@0: * updated to point after the bytes consumed in the conversion call. sl@0: * @param sourceLimit points to the end of the input buffer sl@0: * @param err fills in error status (see ucnv_toUnicode) sl@0: * U_INDEX_OUTOFBOUNDS_ERROR will be set if the input sl@0: * is empty or does not convert to any output (e.g.: pure state-change sl@0: * codes SI/SO, escape sequences for ISO 2022, sl@0: * or if the callback did not output anything, ...). sl@0: * This function will not set a U_BUFFER_OVERFLOW_ERROR because sl@0: * the "buffer" is the return code. However, there might be subsequent output sl@0: * stored in the converter object sl@0: * that will be returned in following calls to this function. sl@0: * @return a UChar32 resulting from the partial conversion of source sl@0: * @see ucnv_toUnicode sl@0: * @see ucnv_toUChars sl@0: * @see ucnv_convert sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE UChar32 U_EXPORT2 sl@0: ucnv_getNextUChar(UConverter * converter, sl@0: const char **source, sl@0: const char * sourceLimit, sl@0: UErrorCode * err); sl@0: sl@0: /** sl@0: * Convert from one external charset to another using two existing UConverters. sl@0: * Internally, two conversions - ucnv_toUnicode() and ucnv_fromUnicode() - sl@0: * are used, "pivoting" through 16-bit Unicode. sl@0: * sl@0: * There is a similar function, ucnv_convert(), sl@0: * which has the following limitations: sl@0: * - it takes charset names, not converter objects, so that sl@0: * - two converters are opened for each call sl@0: * - only single-string conversion is possible, not streaming operation sl@0: * - it does not provide enough information to find out, sl@0: * in case of failure, whether the toUnicode or sl@0: * the fromUnicode conversion failed sl@0: * sl@0: * By contrast, ucnv_convertEx() sl@0: * - takes UConverter parameters instead of charset names sl@0: * - fully exposes the pivot buffer for complete error handling sl@0: * sl@0: * ucnv_convertEx() also provides further convenience: sl@0: * - an option to reset the converters at the beginning sl@0: * (if reset==TRUE, see parameters; sl@0: * also sets *pivotTarget=*pivotSource=pivotStart) sl@0: * - allow NUL-terminated input sl@0: * (only a single NUL byte, will not work for charsets with multi-byte NULs) sl@0: * (if sourceLimit==NULL, see parameters) sl@0: * - terminate with a NUL on output sl@0: * (only a single NUL byte, not useful for charsets with multi-byte NULs), sl@0: * or set U_STRING_NOT_TERMINATED_WARNING if the output exactly fills sl@0: * the target buffer sl@0: * - the pivot buffer can be provided internally; sl@0: * in this case, the caller will not be able to get details about where an sl@0: * error occurred sl@0: * (if pivotStart==NULL, see below) sl@0: * sl@0: * The function returns when one of the following is true: sl@0: * - the entire source text has been converted successfully to the target buffer sl@0: * - a target buffer overflow occurred (U_BUFFER_OVERFLOW_ERROR) sl@0: * - a conversion error occurred sl@0: * (other U_FAILURE(), see description of pErrorCode) sl@0: * sl@0: * Limitation compared to the direct use of sl@0: * ucnv_fromUnicode() and ucnv_toUnicode(): sl@0: * ucnv_convertEx() does not provide offset information. sl@0: * sl@0: * Limitation compared to ucnv_fromUChars() and ucnv_toUChars(): sl@0: * ucnv_convertEx() does not support preflighting directly. sl@0: * sl@0: * Sample code for converting a single string from sl@0: * one external charset to UTF-8, ignoring the location of errors: sl@0: * sl@0: * \code sl@0: * int32_t sl@0: * myToUTF8(UConverter *cnv, sl@0: * const char *s, int32_t length, sl@0: * char *u8, int32_t capacity, sl@0: * UErrorCode *pErrorCode) { sl@0: * UConverter *utf8Cnv; sl@0: * char *target; sl@0: * sl@0: * if(U_FAILURE(*pErrorCode)) { sl@0: * return 0; sl@0: * } sl@0: * sl@0: * utf8Cnv=myGetCachedUTF8Converter(pErrorCode); sl@0: * if(U_FAILURE(*pErrorCode)) { sl@0: * return 0; sl@0: * } sl@0: * sl@0: * target=u8; sl@0: * ucnv_convertEx(cnv, utf8Cnv, sl@0: * &target, u8+capacity, sl@0: * &s, length>=0 ? s+length : NULL, sl@0: * NULL, NULL, NULL, NULL, sl@0: * TRUE, TRUE, sl@0: * pErrorCode); sl@0: * sl@0: * myReleaseCachedUTF8Converter(utf8Cnv); sl@0: * sl@0: * // return the output string length, but without preflighting sl@0: * return (int32_t)(target-u8); sl@0: * } sl@0: * \endcode sl@0: * sl@0: * @param targetCnv Output converter, used to convert from the UTF-16 pivot sl@0: * to the target using ucnv_fromUnicode(). sl@0: * @param sourceCnv Input converter, used to convert from the source to sl@0: * the UTF-16 pivot using ucnv_toUnicode(). sl@0: * @param target I/O parameter, same as for ucnv_fromUChars(). sl@0: * Input: *target points to the beginning of the target buffer. sl@0: * Output: *target points to the first unit after the last char written. sl@0: * @param targetLimit Pointer to the first unit after the target buffer. sl@0: * @param source I/O parameter, same as for ucnv_toUChars(). sl@0: * Input: *source points to the beginning of the source buffer. sl@0: * Output: *source points to the first unit after the last char read. sl@0: * @param sourceLimit Pointer to the first unit after the source buffer. sl@0: * @param pivotStart Pointer to the UTF-16 pivot buffer. If pivotStart==NULL, sl@0: * then an internal buffer is used and the other pivot sl@0: * arguments are ignored and can be NULL as well. sl@0: * @param pivotSource I/O parameter, same as source in ucnv_fromUChars() for sl@0: * conversion from the pivot buffer to the target buffer. sl@0: * @param pivotTarget I/O parameter, same as target in ucnv_toUChars() for sl@0: * conversion from the source buffer to the pivot buffer. sl@0: * It must be pivotStart<=*pivotSource<=*pivotTarget<=pivotLimit sl@0: * and pivotStart[0..ucnv_countAvaiable()]) sl@0: * @return a pointer a string (library owned), or NULL if the index is out of bounds. sl@0: * @see ucnv_countAvailable sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE const char* U_EXPORT2 sl@0: ucnv_getAvailableName(int32_t n); sl@0: sl@0: /** sl@0: * Returns a UEnumeration to enumerate all of the canonical converter sl@0: * names, as per the alias file, regardless of the ability to open each sl@0: * converter. sl@0: * sl@0: * @return A UEnumeration object for getting all the recognized canonical sl@0: * converter names. sl@0: * @see ucnv_getAvailableName sl@0: * @see uenum_close sl@0: * @see uenum_next sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE UEnumeration * U_EXPORT2 sl@0: ucnv_openAllNames(UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Gives the number of aliases for a given converter or alias name. sl@0: * If the alias is ambiguous, then the preferred converter is used sl@0: * and the status is set to U_AMBIGUOUS_ALIAS_WARNING. sl@0: * This method only enumerates the listed entries in the alias file. sl@0: * @param alias alias name sl@0: * @param pErrorCode error status sl@0: * @return number of names on alias list for given alias sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE uint16_t U_EXPORT2 sl@0: ucnv_countAliases(const char *alias, UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Gives the name of the alias at given index of alias list. sl@0: * This method only enumerates the listed entries in the alias file. sl@0: * If the alias is ambiguous, then the preferred converter is used sl@0: * and the status is set to U_AMBIGUOUS_ALIAS_WARNING. sl@0: * @param alias alias name sl@0: * @param n index in alias list sl@0: * @param pErrorCode result of operation sl@0: * @return returns the name of the alias at given index sl@0: * @see ucnv_countAliases sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE const char * U_EXPORT2 sl@0: ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Fill-up the list of alias names for the given alias. sl@0: * This method only enumerates the listed entries in the alias file. sl@0: * If the alias is ambiguous, then the preferred converter is used sl@0: * and the status is set to U_AMBIGUOUS_ALIAS_WARNING. sl@0: * @param alias alias name sl@0: * @param aliases fill-in list, aliases is a pointer to an array of sl@0: * ucnv_countAliases() string-pointers sl@0: * (const char *) that will be filled in. sl@0: * The strings themselves are owned by the library. sl@0: * @param pErrorCode result of operation sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Return a new UEnumeration object for enumerating all the sl@0: * alias names for a given converter that are recognized by a standard. sl@0: * This method only enumerates the listed entries in the alias file. sl@0: * The convrtrs.txt file can be modified to change the results of sl@0: * this function. sl@0: * The first result in this list is the same result given by sl@0: * ucnv_getStandardName, which is the default alias for sl@0: * the specified standard name. The returned object must be closed with sl@0: * uenum_close when you are done with the object. sl@0: * sl@0: * @param convName original converter name sl@0: * @param standard name of the standard governing the names; MIME and IANA sl@0: * are such standards sl@0: * @param pErrorCode The error code sl@0: * @return A UEnumeration object for getting all aliases that are recognized sl@0: * by a standard. If any of the parameters are invalid, NULL sl@0: * is returned. sl@0: * @see ucnv_getStandardName sl@0: * @see uenum_close sl@0: * @see uenum_next sl@0: * @stable ICU 2.2 sl@0: */ sl@0: U_STABLE UEnumeration * U_EXPORT2 sl@0: ucnv_openStandardNames(const char *convName, sl@0: const char *standard, sl@0: UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Gives the number of standards associated to converter names. sl@0: * @return number of standards sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE uint16_t U_EXPORT2 sl@0: ucnv_countStandards(void); sl@0: sl@0: /** sl@0: * Gives the name of the standard at given index of standard list. sl@0: * @param n index in standard list sl@0: * @param pErrorCode result of operation sl@0: * @return returns the name of the standard at given index. Owned by the library. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE const char * U_EXPORT2 sl@0: ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Returns a standard name for a given converter name. sl@0: *

sl@0: * Example alias table:
sl@0: * conv alias1 { STANDARD1 } alias2 { STANDARD1* } sl@0: *

sl@0: * Result of ucnv_getStandardName("conv", "STANDARD1") from example sl@0: * alias table:
sl@0: * "alias2" sl@0: * sl@0: * @param name original converter name sl@0: * @param standard name of the standard governing the names; MIME and IANA sl@0: * are such standards sl@0: * @param pErrorCode result of operation sl@0: * @return returns the standard converter name; sl@0: * if a standard converter name cannot be determined, sl@0: * then NULL is returned. Owned by the library. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE const char * U_EXPORT2 sl@0: ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * This function will return the internal canonical converter name of the sl@0: * tagged alias. This is the opposite of ucnv_openStandardNames, which sl@0: * returns the tagged alias given the canonical name. sl@0: *

sl@0: * Example alias table:
sl@0: * conv alias1 { STANDARD1 } alias2 { STANDARD1* } sl@0: *

sl@0: * Result of ucnv_getStandardName("alias1", "STANDARD1") from example sl@0: * alias table:
sl@0: * "conv" sl@0: * sl@0: * @return returns the canonical converter name; sl@0: * if a standard or alias name cannot be determined, sl@0: * then NULL is returned. The returned string is sl@0: * owned by the library. sl@0: * @see ucnv_getStandardName sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE const char * U_EXPORT2 sl@0: ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * returns the current default converter name. sl@0: * sl@0: * @return returns the current default converter name; sl@0: * if a default converter name cannot be determined, sl@0: * then NULL is returned. sl@0: * Storage owned by the library sl@0: * @see ucnv_setDefaultName sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE const char * U_EXPORT2 sl@0: ucnv_getDefaultName(void); sl@0: sl@0: /** sl@0: * sets the current default converter name. Caller must own the storage for 'name' sl@0: * and preserve it indefinitely. sl@0: * @param name the converter name to be the default (must exist). sl@0: * @see ucnv_getDefaultName sl@0: * @system SYSTEM API sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_setDefaultName(const char *name); sl@0: sl@0: /** sl@0: * Fixes the backslash character mismapping. For example, in SJIS, the backslash sl@0: * character in the ASCII portion is also used to represent the yen currency sign. sl@0: * When mapping from Unicode character 0x005C, it's unclear whether to map the sl@0: * character back to yen or backslash in SJIS. This function will take the input sl@0: * buffer and replace all the yen sign characters with backslash. This is necessary sl@0: * when the user tries to open a file with the input buffer on Windows. sl@0: * This function will test the converter to see whether such mapping is sl@0: * required. You can sometimes avoid using this function by using the correct version sl@0: * of Shift-JIS. sl@0: * sl@0: * @param cnv The converter representing the target codepage. sl@0: * @param source the input buffer to be fixed sl@0: * @param sourceLen the length of the input buffer sl@0: * @see ucnv_isAmbiguous sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen); sl@0: sl@0: /** sl@0: * Determines if the converter contains ambiguous mappings of the same sl@0: * character or not. sl@0: * @param cnv the converter to be tested sl@0: * @return TRUE if the converter contains ambiguous mapping of the same sl@0: * character, FALSE otherwise. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE UBool U_EXPORT2 sl@0: ucnv_isAmbiguous(const UConverter *cnv); sl@0: sl@0: /** sl@0: * Sets the converter to use fallback mapping or not. sl@0: * @param cnv The converter to set the fallback mapping usage on. sl@0: * @param usesFallback TRUE if the user wants the converter to take advantage of the fallback sl@0: * mapping, FALSE otherwise. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE void U_EXPORT2 sl@0: ucnv_setFallback(UConverter *cnv, UBool usesFallback); sl@0: sl@0: /** sl@0: * Determines if the converter uses fallback mappings or not. sl@0: * @param cnv The converter to be tested sl@0: * @return TRUE if the converter uses fallback, FALSE otherwise. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: U_STABLE UBool U_EXPORT2 sl@0: ucnv_usesFallback(const UConverter *cnv); sl@0: sl@0: /** sl@0: * Detects Unicode signature byte sequences at the start of the byte stream sl@0: * and returns the charset name of the indicated Unicode charset. sl@0: * NULL is returned when no Unicode signature is recognized. sl@0: * The number of bytes in the signature is output as well. sl@0: * sl@0: * The caller can ucnv_open() a converter using the charset name. sl@0: * The first code unit (UChar) from the start of the stream will be U+FEFF sl@0: * (the Unicode BOM/signature character) and can usually be ignored. sl@0: * sl@0: * For most Unicode charsets it is also possible to ignore the indicated sl@0: * number of initial stream bytes and start converting after them. sl@0: * However, there are stateful Unicode charsets (UTF-7 and BOCU-1) for which sl@0: * this will not work. Therefore, it is best to ignore the first output UChar sl@0: * instead of the input signature bytes. sl@0: *

sl@0: * Usage: sl@0: * @code sl@0: * UErrorCode err = U_ZERO_ERROR; sl@0: * char input[] = { '\xEF','\xBB', '\xBF','\x41','\x42','\x43' }; sl@0: * int32_t signatureLength = 0; sl@0: * char *encoding = ucnv_detectUnicodeSignatures(input,sizeof(input),&signatureLength,&err); sl@0: * UConverter *conv = NULL; sl@0: * UChar output[100]; sl@0: * UChar *target = output, *out; sl@0: * char *source = input; sl@0: * if(encoding!=NULL && U_SUCCESS(err)){ sl@0: * // should signature be discarded ? sl@0: * conv = ucnv_open(encoding, &err); sl@0: * // do the conversion sl@0: * ucnv_toUnicode(conv, sl@0: * target, output + sizeof(output)/U_SIZEOF_UCHAR, sl@0: * source, input + sizeof(input), sl@0: * NULL, TRUE, &err); sl@0: * out = output; sl@0: * if (discardSignature){ sl@0: * ++out; // ignore initial U+FEFF sl@0: * } sl@0: * while(out != target) { sl@0: * printf("%04x ", *out++); sl@0: * } sl@0: * puts(""); sl@0: * } sl@0: * sl@0: * @endcode sl@0: * sl@0: * @param source The source string in which the signature should be detected. sl@0: * @param sourceLength Length of the input string, or -1 if terminated with a NUL byte. sl@0: * @param signatureLength A pointer to int32_t to receive the number of bytes that make up the signature sl@0: * of the detected UTF. 0 if not detected. sl@0: * Can be a NULL pointer. sl@0: * @param pErrorCode ICU error code in/out parameter. sl@0: * Must fulfill U_SUCCESS before the function call. sl@0: * @return The name of the encoding detected. NULL if encoding is not detected. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: U_STABLE const char* U_EXPORT2 sl@0: ucnv_detectUnicodeSignature(const char* source, sl@0: int32_t sourceLength, sl@0: int32_t *signatureLength, sl@0: UErrorCode *pErrorCode); sl@0: sl@0: /** sl@0: * Returns the number of UChars held in the converter's internal state sl@0: * because more input is needed for completing the conversion. This function is sl@0: * useful for mapping semantics of ICU's converter interface to those of iconv, sl@0: * and this information is not needed for normal conversion. sl@0: * @param cnv The converter in which the input is held sl@0: * @param status ICU error code in/out parameter. sl@0: * Must fulfill U_SUCCESS before the function call. sl@0: * @return The number of UChars in the state. -1 if an error is encountered. sl@0: * @draft ICU 3.4 sl@0: */ sl@0: U_DRAFT int32_t U_EXPORT2 sl@0: ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status); sl@0: sl@0: /** sl@0: * Returns the number of chars held in the converter's internal state sl@0: * because more input is needed for completing the conversion. This function is sl@0: * useful for mapping semantics of ICU's converter interface to those of iconv, sl@0: * and this information is not needed for normal conversion. sl@0: * @param cnv The converter in which the input is held as internal state sl@0: * @param status ICU error code in/out parameter. sl@0: * Must fulfill U_SUCCESS before the function call. sl@0: * @return The number of chars in the state. -1 if an error is encountered. sl@0: * @draft ICU 3.4 sl@0: */ sl@0: U_DRAFT int32_t U_EXPORT2 sl@0: ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status); sl@0: sl@0: #endif sl@0: sl@0: #endif sl@0: /*_UCNV*/