X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/729e4ab9bc6618bc3d8a898e575df7f4019e29ca..9f1b115531acc2f3640893f76e8bcf6680033062:/icuSources/common/unicode/ucnv.h diff --git a/icuSources/common/unicode/ucnv.h b/icuSources/common/unicode/ucnv.h index 98da8ff6..ad718aad 100644 --- a/icuSources/common/unicode/ucnv.h +++ b/icuSources/common/unicode/ucnv.h @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ********************************************************************** -* Copyright (C) 1999-2010, International Business Machines +* Copyright (C) 1999-2014, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * ucnv.h: @@ -18,7 +20,7 @@ /** * \file - * \brief C API: Character conversion + * \brief C API: Character conversion * *

Character Conversion C API

* @@ -39,7 +41,7 @@ * or {@link ucnv_setToUCallBack() } on the converter. The header ucnv_err.h defines * many other callback actions that can be used instead of a character substitution.

* - *

More information about this API can be found in our + *

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

*/ @@ -88,46 +90,82 @@ U_CDECL_BEGIN * @stable ICU 2.0 */ typedef enum { + /** @stable ICU 2.0 */ UCNV_UNSUPPORTED_CONVERTER = -1, + /** @stable ICU 2.0 */ UCNV_SBCS = 0, + /** @stable ICU 2.0 */ UCNV_DBCS = 1, + /** @stable ICU 2.0 */ UCNV_MBCS = 2, + /** @stable ICU 2.0 */ UCNV_LATIN_1 = 3, + /** @stable ICU 2.0 */ UCNV_UTF8 = 4, + /** @stable ICU 2.0 */ UCNV_UTF16_BigEndian = 5, + /** @stable ICU 2.0 */ UCNV_UTF16_LittleEndian = 6, + /** @stable ICU 2.0 */ UCNV_UTF32_BigEndian = 7, + /** @stable ICU 2.0 */ UCNV_UTF32_LittleEndian = 8, + /** @stable ICU 2.0 */ UCNV_EBCDIC_STATEFUL = 9, + /** @stable ICU 2.0 */ UCNV_ISO_2022 = 10, + /** @stable ICU 2.0 */ UCNV_LMBCS_1 = 11, - UCNV_LMBCS_2, + /** @stable ICU 2.0 */ + UCNV_LMBCS_2, + /** @stable ICU 2.0 */ UCNV_LMBCS_3, + /** @stable ICU 2.0 */ UCNV_LMBCS_4, + /** @stable ICU 2.0 */ UCNV_LMBCS_5, + /** @stable ICU 2.0 */ UCNV_LMBCS_6, + /** @stable ICU 2.0 */ UCNV_LMBCS_8, + /** @stable ICU 2.0 */ UCNV_LMBCS_11, + /** @stable ICU 2.0 */ UCNV_LMBCS_16, + /** @stable ICU 2.0 */ UCNV_LMBCS_17, + /** @stable ICU 2.0 */ UCNV_LMBCS_18, + /** @stable ICU 2.0 */ UCNV_LMBCS_19, + /** @stable ICU 2.0 */ UCNV_LMBCS_LAST = UCNV_LMBCS_19, + /** @stable ICU 2.0 */ UCNV_HZ, + /** @stable ICU 2.0 */ UCNV_SCSU, + /** @stable ICU 2.0 */ UCNV_ISCII, + /** @stable ICU 2.0 */ UCNV_US_ASCII, + /** @stable ICU 2.0 */ UCNV_UTF7, + /** @stable ICU 2.2 */ UCNV_BOCU1, + /** @stable ICU 2.2 */ UCNV_UTF16, + /** @stable ICU 2.2 */ UCNV_UTF32, + /** @stable ICU 2.2 */ UCNV_CESU8, + /** @stable ICU 2.4 */ UCNV_IMAP_MAILBOX, + /** @stable ICU 4.8 */ + UCNV_COMPOUND_TEXT, /* Number of converter types for which we have conversion routines. */ UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES - } UConverterType; /** @@ -201,7 +239,7 @@ U_CDECL_END #define UCNV_OPTION_SEP_CHAR ',' /** - * String version of UCNV_OPTION_SEP_CHAR. + * String version of UCNV_OPTION_SEP_CHAR. * @see ucnv_open * @stable ICU 2.0 */ @@ -215,7 +253,7 @@ U_CDECL_END #define UCNV_VALUE_SEP_CHAR '=' /** - * String version of UCNV_VALUE_SEP_CHAR. + * String version of UCNV_VALUE_SEP_CHAR. * @see ucnv_open * @stable ICU 2.0 */ @@ -233,7 +271,7 @@ U_CDECL_END /** * Converter option for specifying a version selector (0..9) for some converters. - * For example, + * For example, * \code * ucnv_open("UTF-7,version=1", &errorCode); * \endcode @@ -305,6 +343,8 @@ ucnv_compareNames(const char *name1, const char *name2); * other than its an alias starting with the letters "cp". Please do not * associate any meaning to these aliases.

* + * \snippet samples/ucnv/convsamp.cpp ucnv_open + * * @param converterName Name of the coded character set table. * This may have options appended to the string. * IANA alias character set names, IBM CCSIDs starting with "ibm-", @@ -323,29 +363,29 @@ ucnv_compareNames(const char *name1, const char *name2); * @see ucnv_compareNames * @stable ICU 2.0 */ -U_STABLE UConverter* U_EXPORT2 +U_STABLE UConverter* U_EXPORT2 ucnv_open(const char *converterName, UErrorCode *err); /** - * Creates a Unicode converter with the names specified as unicode string. + * Creates a Unicode converter with the names specified as unicode string. * The name should be limited to the ASCII-7 alphanumerics range. * The actual name will be resolved with the alias file * using a case-insensitive string comparison that ignores * leading zeroes and all non-alphanumeric characters. * E.g., the names "UTF8", "utf-8", "u*T@f08" and "Utf 8" are all equivalent. * (See also ucnv_compareNames().) - * If NULL is passed for the converter name, it will create + * If NULL is passed for the converter name, it will create * one with the ucnv_getDefaultName() return value. * If the alias is ambiguous, then the preferred converter is used * and the status is set to U_AMBIGUOUS_ALIAS_WARNING. * *

See ucnv_open for the complete details

- * @param name Name of the UConverter table in a zero terminated + * @param name Name of the UConverter table in a zero terminated * Unicode string - * @param err outgoing error status U_MEMORY_ALLOCATION_ERROR, + * @param err outgoing error status U_MEMORY_ALLOCATION_ERROR, * U_FILE_ACCESS_ERROR - * @return the created Unicode converter object, or NULL if an + * @return the created Unicode converter object, or NULL if an * error occured * @see ucnv_open * @see ucnv_openCCSID @@ -353,7 +393,7 @@ ucnv_open(const char *converterName, UErrorCode *err); * @see ucnv_compareNames * @stable ICU 2.0 */ -U_STABLE UConverter* U_EXPORT2 +U_STABLE UConverter* U_EXPORT2 ucnv_openU(const UChar *name, UErrorCode *err); @@ -428,20 +468,20 @@ ucnv_openCCSID(int32_t codepage, /** *

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

- * + * *

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

- * + * *

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

* *

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

- * + * *

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

@@ -456,7 +496,7 @@ ucnv_openCCSID(int32_t codepage, * @see ucnv_close * @stable ICU 2.2 */ -U_STABLE UConverter* U_EXPORT2 +U_STABLE UConverter* U_EXPORT2 ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err); /** @@ -483,10 +523,12 @@ ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode * adjusted pointer and use an accordingly smaller buffer size. * * @param cnv converter to be cloned - * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. + * @param stackBuffer Deprecated functionality as of ICU 52, use NULL.
+ * user allocated space for the new clone. If NULL new memory will be allocated. * If buffer is not large enough, new memory will be allocated. * Clients can use the U_CNV_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations. - * @param pBufferSize pointer to size of allocated space. pBufferSize must not be NULL. + * @param pBufferSize Deprecated functionality as of ICU 52, use NULL or 1.
+ * pointer to size of allocated space. * @param status to indicate whether the operation went on smoothly or there were errors * An informational status value, U_SAFECLONE_ALLOCATED_WARNING, * is used if any allocations were necessary. @@ -496,20 +538,24 @@ ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode * @return pointer to the new clone * @stable ICU 2.0 */ -U_STABLE UConverter * U_EXPORT2 -ucnv_safeClone(const UConverter *cnv, +U_STABLE UConverter * U_EXPORT2 +ucnv_safeClone(const UConverter *cnv, void *stackBuffer, - int32_t *pBufferSize, + int32_t *pBufferSize, UErrorCode *status); +#ifndef U_HIDE_DEPRECATED_API + /** * \def U_CNV_SAFECLONE_BUFFERSIZE * Definition of a buffer size that is designed to be large enough for * converters to be cloned with ucnv_safeClone(). - * @stable ICU 2.0 + * @deprecated ICU 52. Do not rely on ucnv_safeClone() cloning into any provided buffer. */ #define U_CNV_SAFECLONE_BUFFERSIZE 1024 +#endif /* U_HIDE_DEPRECATED_API */ + /** * Deletes the unicode converter and releases resources associated * with just this instance. @@ -541,7 +587,7 @@ U_DEFINE_LOCAL_OPEN_POINTER(LocalUConverterPointer, UConverter, ucnv_close); U_NAMESPACE_END -#endif +#endif // U_SHOW_CPLUSPLUS_API /** * Fills in the output parameter, subChars, with the substitution characters @@ -551,7 +597,7 @@ U_NAMESPACE_END * * @param converter the Unicode converter * @param subChars the subsitution characters - * @param len on input the capacity of subChars, on output the number + * @param len on input the capacity of subChars, on output the number * of bytes copied to it * @param err the outgoing error status code. * If the substitution character array is too small, an @@ -649,7 +695,7 @@ ucnv_getInvalidChars(const UConverter *converter, * * @param converter the Unicode converter * @param errUChars the UChars which were in error - * @param len on input the capacity of errUChars, on output the number of + * @param len on input the capacity of errUChars, on output the number of * UChars which were copied to it * @param err the error status code. * If the substitution character array is too small, an @@ -680,7 +726,7 @@ ucnv_reset(UConverter *converter); * @param converter the Unicode converter * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucnv_resetToUnicode(UConverter *converter); /** @@ -691,7 +737,7 @@ ucnv_resetToUnicode(UConverter *converter); * @param converter the Unicode converter * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucnv_resetFromUnicode(UConverter *converter); /** @@ -735,8 +781,10 @@ ucnv_resetFromUnicode(UConverter *converter); * - ISO-2022-CN: 8 (4-byte designator sequences + 2-byte SS2/SS3 + DBCS) * * @param converter The Unicode converter. - * @return The maximum number of bytes per UChar that are output by ucnv_fromUnicode(), - * to be used together with UCNV_GET_MAX_BYTES_FOR_STRING for buffer allocation. + * @return The maximum number of bytes per UChar (16 bit code unit) + * that are output by ucnv_fromUnicode(), + * to be used together with UCNV_GET_MAX_BYTES_FOR_STRING + * for buffer allocation. * * @see UCNV_GET_MAX_BYTES_FOR_STRING * @see ucnv_getMinCharSize @@ -768,10 +816,10 @@ ucnv_getMaxCharSize(const UConverter *converter); (((int32_t)(length)+10)*(int32_t)(maxCharSize)) /** - * Returns the minimum byte length for characters in this codepage. + * Returns the minimum byte length (per codepoint) for characters in this codepage. * This is usually either 1 or 2. * @param converter the Unicode converter - * @return the minimum number of bytes allowed by this particular converter + * @return the minimum number of bytes per codepoint allowed by this particular converter * @see ucnv_getMaxCharSize * @stable ICU 2.0 */ @@ -779,7 +827,7 @@ U_STABLE int8_t U_EXPORT2 ucnv_getMinCharSize(const UConverter *converter); /** - * Returns the display name of the converter passed in based on the Locale + * Returns the display name of the converter passed in based on the Locale * passed in. If the locale contains no display name, the internal ASCII * name will be filled in. * @@ -801,7 +849,7 @@ ucnv_getDisplayName(const UConverter *converter, /** * Gets the internal, canonical name of the converter (zero-terminated). - * The lifetime of the returned string will be that of the converter + * The lifetime of the returned string will be that of the converter * passed to this function. * @param converter the Unicode converter * @param err UErrorCode status @@ -809,7 +857,7 @@ ucnv_getDisplayName(const UConverter *converter, * @see ucnv_getDisplayName * @stable ICU 2.0 */ -U_STABLE const char * U_EXPORT2 +U_STABLE const char * U_EXPORT2 ucnv_getName(const UConverter *converter, UErrorCode *err); /** @@ -840,10 +888,10 @@ ucnv_getCCSID(const UConverter *converter, UErrorCode *err); /** - * Gets a codepage platform associated with the converter. Currently, + * Gets a codepage platform associated with the converter. Currently, * only UCNV_IBM will be returned. - * Does not test if the converter is NULL or if converter's data - * table is NULL. + * Does not test if the converter is NULL or if converter's data + * table is NULL. * @param converter the Unicode converter * @param err the error status code. * @return The codepage platform @@ -855,7 +903,7 @@ ucnv_getPlatform(const UConverter *converter, /** * Gets the type of the converter - * e.g. SBCS, MBCS, DBCS, UTF8, UTF16_BE, UTF16_LE, ISO_2022, + * e.g. SBCS, MBCS, DBCS, UTF8, UTF16_BE, UTF16_LE, ISO_2022, * EBCDIC_STATEFUL, LATIN_1 * @param converter a valid, opened converter * @return the type of the converter @@ -867,20 +915,20 @@ ucnv_getType(const UConverter * converter); /** * Gets the "starter" (lead) bytes for converters of type MBCS. * Will fill in an U_ILLEGAL_ARGUMENT_ERROR if converter passed in - * is not MBCS. Fills in an array of type UBool, with the value of the byte + * is not MBCS. Fills in an array of type UBool, with the value of the byte * as offset to the array. For example, if (starters[0x20] == TRUE) at return, * it means that the byte 0x20 is a starter byte in this converter. * Context pointers are always owned by the caller. - * + * * @param converter a valid, opened converter of type MBCS * @param starters an array of size 256 to be filled in - * @param err error status, U_ILLEGAL_ARGUMENT_ERROR if the + * @param err error status, U_ILLEGAL_ARGUMENT_ERROR if the * converter is not a type which can return starters. * @see ucnv_getType * @stable ICU 2.0 */ U_STABLE void U_EXPORT2 -ucnv_getStarters(const UConverter* converter, +ucnv_getStarters(const UConverter* converter, UBool starters[256], UErrorCode* err); @@ -895,8 +943,13 @@ typedef enum UConverterUnicodeSet { UCNV_ROUNDTRIP_SET, /** Select the set of Unicode code points with roundtrip or fallback mappings. @stable ICU 4.0 */ UCNV_ROUNDTRIP_AND_FALLBACK_SET, - /** Number of UConverterUnicodeSet selectors. @stable ICU 2.6 */ +#ifndef U_HIDE_DEPRECATED_API + /** + * Number of UConverterUnicodeSet selectors. + * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. + */ UCNV_SET_COUNT +#endif // U_HIDE_DEPRECATED_API } UConverterUnicodeSet; @@ -953,7 +1006,7 @@ ucnv_getUnicodeSet(const UConverter *cnv, /** * Gets the current calback function used by the converter when an illegal - * or invalid codepage sequence is found. + * or invalid codepage sequence is found. * Context pointers are always owned by the caller. * * @param converter the unicode converter @@ -968,7 +1021,7 @@ ucnv_getToUCallBack (const UConverter * converter, const void **context); /** - * Gets the current callback function used by the converter when illegal + * Gets the current callback function used by the converter when illegal * or invalid Unicode sequence is found. * Context pointers are always owned by the caller. * @@ -1034,26 +1087,26 @@ ucnv_setFromUCallBack (UConverter * converter, * characters. This function is optimized for converting a continuous * stream of data in buffer-sized chunks, where the entire source and * target does not fit in available buffers. - * - * The source pointer is an in/out parameter. It starts out pointing where the - * conversion is to begin, and ends up pointing after the last UChar consumed. - * + * + * The source pointer is an in/out parameter. It starts out pointing where the + * conversion is to begin, and ends up pointing after the last UChar consumed. + * * Target similarly starts out pointer at the first available byte in the output * buffer, and ends up pointing after the last byte written to the output. - * - * The converter always attempts to consume the entire source buffer, unless + * + * The converter always attempts to consume the entire source buffer, unless * (1.) the target buffer is full, or (2.) a failing error is returned from the * current callback function. When a successful error status has been * returned, it means that all of the source buffer has been * consumed. At that point, the caller should reset the source and * sourceLimit pointers to point to the next chunk. - * + * * At the end of the stream (flush==TRUE), the input is completely consumed * when *source==sourceLimit and no error code is set. * The converter object is then automatically reset by this function. * (This means that a converter need not be reset explicitly between data * streams if it finishes the previous stream without errors.) - * + * * This is a stateful conversion. Additionally, even when all source data has * been consumed, some data may be in the converters' internal state. * Call this function repeatedly, updating the target pointers with @@ -1066,20 +1119,20 @@ ucnv_setFromUCallBack (UConverter * converter, * codepage characters to. Output : points to after the last codepage character copied * to target. * @param targetLimit the pointer just after last of the target buffer - * @param source I/O parameter, pointer to pointer to the source Unicode character buffer. + * @param source I/O parameter, pointer to pointer to the source Unicode character buffer. * @param sourceLimit the pointer just after the last of the source buffer * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number * of allocated cells as target. Will fill in offsets from target to source pointer * e.g: offsets[3] is equal to 6, it means that the target[3] was a result of transcoding source[6] * For output data carried across calls, and other data without a specific source character - * (such as from escape sequences or callbacks) -1 will be placed for offsets. + * (such as from escape sequences or callbacks) -1 will be placed for offsets. * @param flush set to TRUE if the current source buffer is the last available * chunk of the source, FALSE otherwise. Note that if a failing status is returned, * this function may have to be called multiple times with flush set to TRUE until * the source buffer is consumed. * @param err the error status. U_ILLEGAL_ARGUMENT_ERROR will be set if the * converter is NULL. - * U_BUFFER_OVERFLOW_ERROR will be set if the target is full and there is + * U_BUFFER_OVERFLOW_ERROR will be set if the target is full and there is * still data to be written to the target. * @see ucnv_fromUChars * @see ucnv_convert @@ -1087,7 +1140,7 @@ ucnv_setFromUCallBack (UConverter * converter, * @see ucnv_setToUCallBack * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucnv_fromUnicode (UConverter * converter, char **target, const char *targetLimit, @@ -1102,15 +1155,15 @@ ucnv_fromUnicode (UConverter * converter, * characters. This function is optimized for converting a continuous * stream of data in buffer-sized chunks, where the entire source and * target does not fit in available buffers. - * - * The source pointer is an in/out parameter. It starts out pointing where the - * conversion is to begin, and ends up pointing after the last byte of source consumed. - * + * + * The source pointer is an in/out parameter. It starts out pointing where the + * conversion is to begin, and ends up pointing after the last byte of source consumed. + * * Target similarly starts out pointer at the first available UChar in the output - * buffer, and ends up pointing after the last UChar written to the output. + * buffer, and ends up pointing after the last UChar written to the output. * It does NOT necessarily keep UChar sequences together. - * - * The converter always attempts to consume the entire source buffer, unless + * + * The converter always attempts to consume the entire source buffer, unless * (1.) the target buffer is full, or (2.) a failing error is returned from the * current callback function. When a successful error status has been * returned, it means that all of the source buffer has been @@ -1122,7 +1175,7 @@ ucnv_fromUnicode (UConverter * converter, * The converter object is then automatically reset by this function. * (This means that a converter need not be reset explicitly between data * streams if it finishes the previous stream without errors.) - * + * * This is a stateful conversion. Additionally, even when all source data has * been consumed, some data may be in the converters' internal state. * Call this function repeatedly, updating the target pointers with @@ -1134,21 +1187,21 @@ ucnv_fromUnicode (UConverter * converter, * @param target I/O parameter. Input : Points to the beginning of the buffer to copy * UChars into. Output : points to after the last UChar copied. * @param targetLimit the pointer just after the end of the target buffer - * @param source I/O parameter, pointer to pointer to the source codepage buffer. + * @param source I/O parameter, pointer to pointer to the source codepage buffer. * @param sourceLimit the pointer to the byte after the end of the source buffer * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number * of allocated cells as target. Will fill in offsets from target to source pointer * e.g: offsets[3] is equal to 6, it means that the target[3] was a result of transcoding source[6] * For output data carried across calls, and other data without a specific source character - * (such as from escape sequences or callbacks) -1 will be placed for offsets. + * (such as from escape sequences or callbacks) -1 will be placed for offsets. * @param flush set to TRUE if the current source buffer is the last available * chunk of the source, FALSE otherwise. Note that if a failing status is returned, * this function may have to be called multiple times with flush set to TRUE until * the source buffer is consumed. * @param err the error status. U_ILLEGAL_ARGUMENT_ERROR will be set if the * converter is NULL. - * U_BUFFER_OVERFLOW_ERROR will be set if the target is full and there is - * still data to be written to the target. + * U_BUFFER_OVERFLOW_ERROR will be set if the target is full and there is + * still data to be written to the target. * @see ucnv_fromUChars * @see ucnv_convert * @see ucnv_getMinCharSize @@ -1156,7 +1209,7 @@ ucnv_fromUnicode (UConverter * converter, * @see ucnv_getNextUChar * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucnv_toUnicode(UConverter *converter, UChar **target, const UChar *targetLimit, @@ -1287,8 +1340,8 @@ ucnv_toUChars(UConverter *cnv, * updated to point after the bytes consumed in the conversion call. * @param sourceLimit points to the end of the input buffer * @param err fills in error status (see ucnv_toUnicode) - * U_INDEX_OUTOFBOUNDS_ERROR will be set if the input - * is empty or does not convert to any output (e.g.: pure state-change + * U_INDEX_OUTOFBOUNDS_ERROR will be set if the input + * is empty or does not convert to any output (e.g.: pure state-change * codes SI/SO, escape sequences for ISO 2022, * or if the callback did not output anything, ...). * This function will not set a U_BUFFER_OVERFLOW_ERROR because @@ -1392,7 +1445,7 @@ ucnv_getNextUChar(UConverter * converter, * NULL, NULL, NULL, NULL, * TRUE, TRUE, * pErrorCode); - * + * * myReleaseCachedUTF8Converter(utf8Cnv); * * // return the output string length, but without preflighting @@ -1680,7 +1733,7 @@ ucnv_openAllNames(UErrorCode *pErrorCode); * @return number of names on alias list for given alias * @stable ICU 2.0 */ -U_STABLE uint16_t U_EXPORT2 +U_STABLE uint16_t U_EXPORT2 ucnv_countAliases(const char *alias, UErrorCode *pErrorCode); /** @@ -1695,7 +1748,7 @@ ucnv_countAliases(const char *alias, UErrorCode *pErrorCode); * @see ucnv_countAliases * @stable ICU 2.0 */ -U_STABLE const char * U_EXPORT2 +U_STABLE const char * U_EXPORT2 ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode); /** @@ -1711,7 +1764,7 @@ ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode); * @param pErrorCode result of operation * @stable ICU 2.0 */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode); /** @@ -1821,6 +1874,7 @@ ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErro U_STABLE const char * U_EXPORT2 ucnv_getDefaultName(void); +#ifndef U_HIDE_SYSTEM_API /** * This function is not thread safe. DO NOT call this function when ANY ICU * function is being used from more than one thread! This function sets the @@ -1839,11 +1893,12 @@ ucnv_getDefaultName(void); */ U_STABLE void U_EXPORT2 ucnv_setDefaultName(const char *name); +#endif /* U_HIDE_SYSTEM_API */ /** - * Fixes the backslash character mismapping. For example, in SJIS, the backslash - * character in the ASCII portion is also used to represent the yen currency sign. - * When mapping from Unicode character 0x005C, it's unclear whether to map the + * Fixes the backslash character mismapping. For example, in SJIS, the backslash + * character in the ASCII portion is also used to represent the yen currency sign. + * When mapping from Unicode character 0x005C, it's unclear whether to map the * character back to yen or backslash in SJIS. This function will take the input * buffer and replace all the yen sign characters with backslash. This is necessary * when the user tries to open a file with the input buffer on Windows. @@ -1864,7 +1919,7 @@ ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen); * Determines if the converter contains ambiguous mappings of the same * character or not. * @param cnv the converter to be tested - * @return TRUE if the converter contains ambiguous mapping of the same + * @return TRUE if the converter contains ambiguous mapping of the same * character, FALSE otherwise. * @stable ICU 2.0 */ @@ -1881,12 +1936,12 @@ ucnv_isAmbiguous(const UConverter *cnv); * http://www.icu-project.org/userguide/conversion-data.html#ucmformat * * @param cnv The converter to set the fallback mapping usage on. - * @param usesFallback TRUE if the user wants the converter to take advantage of the fallback + * @param usesFallback TRUE if the user wants the converter to take advantage of the fallback * mapping, FALSE otherwise. * @stable ICU 2.0 * @see ucnv_usesFallback */ -U_STABLE void U_EXPORT2 +U_STABLE void U_EXPORT2 ucnv_setFallback(UConverter *cnv, UBool usesFallback); /** @@ -1898,7 +1953,7 @@ ucnv_setFallback(UConverter *cnv, UBool usesFallback); * @stable ICU 2.0 * @see ucnv_setFallback */ -U_STABLE UBool U_EXPORT2 +U_STABLE UBool U_EXPORT2 ucnv_usesFallback(const UConverter *cnv); /** @@ -1918,43 +1973,16 @@ ucnv_usesFallback(const UConverter *cnv); * instead of the input signature bytes. *

* Usage: - * @code - * UErrorCode err = U_ZERO_ERROR; - * char input[] = { '\xEF','\xBB', '\xBF','\x41','\x42','\x43' }; - * int32_t signatureLength = 0; - * char *encoding = ucnv_detectUnicodeSignature(input,sizeof(input),&signatureLength,&err); - * UConverter *conv = NULL; - * UChar output[100]; - * UChar *target = output, *out; - * char *source = input; - * if(encoding!=NULL && U_SUCCESS(err)){ - * // should signature be discarded ? - * conv = ucnv_open(encoding, &err); - * // do the conversion - * ucnv_toUnicode(conv, - * target, output + sizeof(output)/U_SIZEOF_UCHAR, - * source, input + sizeof(input), - * NULL, TRUE, &err); - * out = output; - * if (discardSignature){ - * ++out; // ignore initial U+FEFF - * } - * while(out != target) { - * printf("%04x ", *out++); - * } - * puts(""); - * } - * - * @endcode + * \snippet samples/ucnv/convsamp.cpp ucnv_detectUnicodeSignature * * @param source The source string in which the signature should be detected. * @param sourceLength Length of the input string, or -1 if terminated with a NUL byte. - * @param signatureLength A pointer to int32_t to receive the number of bytes that make up the signature + * @param signatureLength A pointer to int32_t to receive the number of bytes that make up the signature * of the detected UTF. 0 if not detected. * Can be a NULL pointer. * @param pErrorCode ICU error code in/out parameter. * Must fulfill U_SUCCESS before the function call. - * @return The name of the encoding detected. NULL if encoding is not detected. + * @return The name of the encoding detected. NULL if encoding is not detected. * @stable ICU 2.4 */ U_STABLE const char* U_EXPORT2 @@ -1964,8 +1992,8 @@ ucnv_detectUnicodeSignature(const char* source, UErrorCode *pErrorCode); /** - * Returns the number of UChars held in the converter's internal state - * because more input is needed for completing the conversion. This function is + * Returns the number of UChars held in the converter's internal state + * because more input is needed for completing the conversion. This function is * useful for mapping semantics of ICU's converter interface to those of iconv, * and this information is not needed for normal conversion. * @param cnv The converter in which the input is held @@ -1979,7 +2007,7 @@ ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status); /** * Returns the number of chars held in the converter's internal state - * because more input is needed for completing the conversion. This function is + * because more input is needed for completing the conversion. This function is * useful for mapping semantics of ICU's converter interface to those of iconv, * and this information is not needed for normal conversion. * @param cnv The converter in which the input is held as internal state @@ -1991,6 +2019,24 @@ ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status); U_STABLE int32_t U_EXPORT2 ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status); +/** + * Returns whether or not the charset of the converter has a fixed number of bytes + * per charset character. + * An example of this are converters that are of the type UCNV_SBCS or UCNV_DBCS. + * Another example is UTF-32 which is always 4 bytes per character. + * A Unicode code point may be represented by more than one UTF-8 or UTF-16 code unit + * but a UTF-32 converter encodes each code point with 4 bytes. + * Note: This method is not intended to be used to determine whether the charset has a + * fixed ratio of bytes to Unicode codes units for any particular Unicode encoding form. + * FALSE is returned with the UErrorCode if error occurs or cnv is NULL. + * @param cnv The converter to be tested + * @param status ICU error code in/out paramter + * @return TRUE if the converter is fixed-width + * @stable ICU 4.8 + */ +U_STABLE UBool U_EXPORT2 +ucnv_isFixedWidth(UConverter *cnv, UErrorCode *status); + #endif #endif