os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/ucnv.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/ucnv.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1871 @@
     1.4 +/*
     1.5 +**********************************************************************
     1.6 +*   Copyright (C) 1999-2005, International Business Machines
     1.7 +*   Corporation and others.  All Rights Reserved.
     1.8 +**********************************************************************
     1.9 + *  ucnv.h:
    1.10 + *  External APIs for the ICU's codeset conversion library
    1.11 + *  Bertrand A. Damiba
    1.12 + *
    1.13 + * Modification History:
    1.14 + *
    1.15 + *   Date        Name        Description
    1.16 + *   04/04/99    helena      Fixed internal header inclusion.
    1.17 + *   05/11/00    helena      Added setFallback and usesFallback APIs.
    1.18 + *   06/29/2000  helena      Major rewrite of the callback APIs.
    1.19 + *   12/07/2000  srl         Update of documentation
    1.20 + */
    1.21 +
    1.22 +/**
    1.23 + * \file
    1.24 + * \brief C API: Character conversion 
    1.25 + *
    1.26 + * <h2>Character Conversion C API</h2>
    1.27 + *
    1.28 + * <p>This API is used to convert codepage or character encoded data to and
    1.29 + * from UTF-16. You can open a converter with {@link ucnv_open() }. With that
    1.30 + * converter, you can get its properties, set options, convert your data and
    1.31 + * close the converter.</p>
    1.32 + *
    1.33 + * <p>Since many software programs recogize different converter names for
    1.34 + * different types of converters, there are other functions in this API to
    1.35 + * iterate over the converter aliases. The functions {@link ucnv_getAvailableName() },
    1.36 + * {@link ucnv_getAlias() } and {@link ucnv_getStandardName() } are some of the
    1.37 + * more frequently used alias functions to get this information.</p>
    1.38 + *
    1.39 + * <p>When a converter encounters an illegal, irregular, invalid or unmappable character
    1.40 + * its default behavior is to use a substitution character to replace the
    1.41 + * bad byte sequence. This behavior can be changed by using {@link ucnv_setFromUCallBack() }
    1.42 + * or {@link ucnv_setToUCallBack() } on the converter. The header ucnv_err.h defines
    1.43 + * many other callback actions that can be used instead of a character substitution.</p>
    1.44 + *
    1.45 + * <p>More information about this API can be found in our 
    1.46 + * <a href="http://icu.sourceforge.net/userguide/conversion.html">User's
    1.47 + * Guide</a>.</p>
    1.48 + */
    1.49 +
    1.50 +#ifndef UCNV_H
    1.51 +#define UCNV_H
    1.52 +
    1.53 +#include "unicode/ucnv_err.h"
    1.54 +#include "unicode/uenum.h"
    1.55 +
    1.56 +#ifndef __USET_H__
    1.57 +
    1.58 +/**
    1.59 + * USet is the C API type for Unicode sets.
    1.60 + * It is forward-declared here to avoid including the header file if related
    1.61 + * conversion APIs are not used.
    1.62 + * See unicode/uset.h
    1.63 + *
    1.64 + * @see ucnv_getUnicodeSet
    1.65 + * @stable ICU 2.6
    1.66 + */
    1.67 +struct USet;
    1.68 +/** @stable ICU 2.6 */
    1.69 +typedef struct USet USet;
    1.70 +
    1.71 +#endif
    1.72 +
    1.73 +#if !UCONFIG_NO_CONVERSION
    1.74 +
    1.75 +U_CDECL_BEGIN
    1.76 +
    1.77 +/** Maximum length of a converter name including the terminating NULL @stable ICU 2.0 */
    1.78 +#define UCNV_MAX_CONVERTER_NAME_LENGTH 60
    1.79 +/** Maximum length of a converter name including path and terminating NULL @stable ICU 2.0 */
    1.80 +#define UCNV_MAX_FULL_FILE_NAME_LENGTH (600+UCNV_MAX_CONVERTER_NAME_LENGTH)
    1.81 +
    1.82 +/** Shift in for EBDCDIC_STATEFUL and iso2022 states @stable ICU 2.0 */
    1.83 +#define  UCNV_SI 0x0F
    1.84 +/** Shift out for EBDCDIC_STATEFUL and iso2022 states @stable ICU 2.0 */
    1.85 +#define  UCNV_SO 0x0E
    1.86 +
    1.87 +/**
    1.88 + * Enum for specifying basic types of converters
    1.89 + * @see ucnv_getType
    1.90 + * @stable ICU 2.0
    1.91 + */
    1.92 +typedef enum {
    1.93 +    UCNV_UNSUPPORTED_CONVERTER = -1,
    1.94 +    UCNV_SBCS = 0,
    1.95 +    UCNV_DBCS = 1,
    1.96 +    UCNV_MBCS = 2,
    1.97 +    UCNV_LATIN_1 = 3,
    1.98 +    UCNV_UTF8 = 4,
    1.99 +    UCNV_UTF16_BigEndian = 5,
   1.100 +    UCNV_UTF16_LittleEndian = 6,
   1.101 +    UCNV_UTF32_BigEndian = 7,
   1.102 +    UCNV_UTF32_LittleEndian = 8,
   1.103 +    UCNV_EBCDIC_STATEFUL = 9,
   1.104 +    UCNV_ISO_2022 = 10,
   1.105 +
   1.106 +    UCNV_LMBCS_1 = 11,
   1.107 +    UCNV_LMBCS_2, 
   1.108 +    UCNV_LMBCS_3,
   1.109 +    UCNV_LMBCS_4,
   1.110 +    UCNV_LMBCS_5,
   1.111 +    UCNV_LMBCS_6,
   1.112 +    UCNV_LMBCS_8,
   1.113 +    UCNV_LMBCS_11,
   1.114 +    UCNV_LMBCS_16,
   1.115 +    UCNV_LMBCS_17,
   1.116 +    UCNV_LMBCS_18,
   1.117 +    UCNV_LMBCS_19,
   1.118 +    UCNV_LMBCS_LAST = UCNV_LMBCS_19,
   1.119 +    UCNV_HZ,
   1.120 +    UCNV_SCSU,
   1.121 +    UCNV_ISCII,
   1.122 +    UCNV_US_ASCII,
   1.123 +    UCNV_UTF7,
   1.124 +    UCNV_BOCU1,
   1.125 +    UCNV_UTF16,
   1.126 +    UCNV_UTF32,
   1.127 +    UCNV_CESU8,
   1.128 +    UCNV_IMAP_MAILBOX,
   1.129 +
   1.130 +    /* Number of converter types for which we have conversion routines. */
   1.131 +    UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES
   1.132 +
   1.133 +} UConverterType;
   1.134 +
   1.135 +/**
   1.136 + * Enum for specifying which platform a converter ID refers to.
   1.137 + * The use of platform/CCSID is not recommended. See ucnv_openCCSID().
   1.138 + *
   1.139 + * @see ucnv_getPlatform
   1.140 + * @see ucnv_openCCSID
   1.141 + * @see ucnv_getCCSID
   1.142 + * @stable ICU 2.0
   1.143 + */
   1.144 +typedef enum {
   1.145 +    UCNV_UNKNOWN = -1,
   1.146 +    UCNV_IBM = 0
   1.147 +} UConverterPlatform;
   1.148 +
   1.149 +/**
   1.150 + * Function pointer for error callback in the codepage to unicode direction.
   1.151 + * Called when an error has occured in conversion to unicode, or on open/close of the callback (see reason).
   1.152 + * @param context Pointer to the callback's private data
   1.153 + * @param args Information about the conversion in progress
   1.154 + * @param codeUnits Points to 'length' bytes of the concerned codepage sequence
   1.155 + * @param length Size (in bytes) of the concerned codepage sequence
   1.156 + * @param reason Defines the reason the callback was invoked
   1.157 + * @param pErrorCode    ICU error code in/out parameter.
   1.158 + *                      For converter callback functions, set to a conversion error
   1.159 + *                      before the call, and the callback may reset it to U_ZERO_ERROR.
   1.160 + * @see ucnv_setToUCallBack
   1.161 + * @see UConverterToUnicodeArgs
   1.162 + * @stable ICU 2.0
   1.163 + */
   1.164 +typedef void (U_EXPORT2 *UConverterToUCallback) (
   1.165 +                  const void* context,
   1.166 +                  UConverterToUnicodeArgs *args,
   1.167 +                  const char *codeUnits,
   1.168 +                  int32_t length,
   1.169 +                  UConverterCallbackReason reason,
   1.170 +                  UErrorCode *pErrorCode);
   1.171 +
   1.172 +/**
   1.173 + * Function pointer for error callback in the unicode to codepage direction.
   1.174 + * Called when an error has occured in conversion from unicode, or on open/close of the callback (see reason).
   1.175 + * @param context Pointer to the callback's private data
   1.176 + * @param args Information about the conversion in progress
   1.177 + * @param codeUnits Points to 'length' UChars of the concerned Unicode sequence
   1.178 + * @param length Size (in bytes) of the concerned codepage sequence
   1.179 + * @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.
   1.180 + * @param reason Defines the reason the callback was invoked
   1.181 + * @param pErrorCode    ICU error code in/out parameter.
   1.182 + *                      For converter callback functions, set to a conversion error
   1.183 + *                      before the call, and the callback may reset it to U_ZERO_ERROR.
   1.184 + * @see ucnv_setFromUCallBack
   1.185 + * @stable ICU 2.0
   1.186 + */
   1.187 +typedef void (U_EXPORT2 *UConverterFromUCallback) (
   1.188 +                    const void* context,
   1.189 +                    UConverterFromUnicodeArgs *args,
   1.190 +                    const UChar* codeUnits,
   1.191 +                    int32_t length,
   1.192 +                    UChar32 codePoint,
   1.193 +                    UConverterCallbackReason reason,
   1.194 +                    UErrorCode *pErrorCode);
   1.195 +
   1.196 +U_CDECL_END
   1.197 +
   1.198 +/**
   1.199 + * Character that separates converter names from options and options from each other.
   1.200 + * @see ucnv_open
   1.201 + * @stable ICU 2.0
   1.202 + */
   1.203 +#define UCNV_OPTION_SEP_CHAR ','
   1.204 +
   1.205 +/**
   1.206 + * String version of UCNV_OPTION_SEP_CHAR. 
   1.207 + * @see ucnv_open
   1.208 + * @stable ICU 2.0
   1.209 + */
   1.210 +#define UCNV_OPTION_SEP_STRING ","
   1.211 +
   1.212 +/**
   1.213 + * Character that separates a converter option from its value.
   1.214 + * @see ucnv_open
   1.215 + * @stable ICU 2.0
   1.216 + */
   1.217 +#define UCNV_VALUE_SEP_CHAR '='
   1.218 +
   1.219 +/**
   1.220 + * String version of UCNV_VALUE_SEP_CHAR. 
   1.221 + * @see ucnv_open
   1.222 + * @stable ICU 2.0
   1.223 + */
   1.224 +#define UCNV_VALUE_SEP_STRING "="
   1.225 +
   1.226 +/**
   1.227 + * Converter option for specifying a locale.
   1.228 + * For example, ucnv_open("SCSU,locale=ja", &errorCode);
   1.229 + * See convrtrs.txt.
   1.230 + *
   1.231 + * @see ucnv_open
   1.232 + * @stable ICU 2.0
   1.233 + */
   1.234 +#define UCNV_LOCALE_OPTION_STRING ",locale="
   1.235 +
   1.236 +/**
   1.237 + * Converter option for specifying a version selector (0..9) for some converters.
   1.238 + * For example, ucnv_open("UTF-7,version=1", &errorCode);
   1.239 + * See convrtrs.txt.
   1.240 + *
   1.241 + * @see ucnv_open
   1.242 + * @stable ICU 2.4
   1.243 + */
   1.244 +#define UCNV_VERSION_OPTION_STRING ",version="
   1.245 +
   1.246 +/**
   1.247 + * Converter option for EBCDIC SBCS or mixed-SBCS/DBCS (stateful) codepages.
   1.248 + * Swaps Unicode mappings for EBCDIC LF and NL codes, as used on
   1.249 + * S/390 (z/OS) Unix System Services (Open Edition).
   1.250 + * For example, ucnv_open("ibm-1047,swaplfnl", &errorCode);
   1.251 + * See convrtrs.txt.
   1.252 + *
   1.253 + * @see ucnv_open
   1.254 + * @stable ICU 2.4
   1.255 + */
   1.256 +#define UCNV_SWAP_LFNL_OPTION_STRING ",swaplfnl"
   1.257 +
   1.258 +/**
   1.259 + * Do a fuzzy compare of a two converter/alias names.  The comparison
   1.260 + * is case-insensitive.  It also ignores the characters '-', '_', and
   1.261 + * ' ' (dash, underscore, and space).  Thus the strings "UTF-8",
   1.262 + * "utf_8", and "Utf 8" are exactly equivalent.
   1.263 + * 
   1.264 + * @param name1 a converter name or alias, zero-terminated
   1.265 + * @param name2 a converter name or alias, zero-terminated
   1.266 + * @return 0 if the names match, or a negative value if the name1
   1.267 + * lexically precedes name2, or a positive value if the name1
   1.268 + * lexically follows name2.
   1.269 + * @stable ICU 2.0
   1.270 + */
   1.271 +U_STABLE int U_EXPORT2
   1.272 +ucnv_compareNames(const char *name1, const char *name2);
   1.273 +
   1.274 +
   1.275 +/**
   1.276 + * Creates a UConverter object with the names specified as a C string.
   1.277 + * The actual name will be resolved with the alias file
   1.278 + * using a case-insensitive string comparison that ignores
   1.279 + * the delimiters '-', '_', and ' ' (dash, underscore, and space).
   1.280 + * E.g., the names "UTF8", "utf-8", and "Utf 8" are all equivalent.
   1.281 + * If <code>NULL</code> is passed for the converter name, it will create one with the
   1.282 + * getDefaultName return value.
   1.283 + *
   1.284 + * <p>A converter name for ICU 1.5 and above may contain options
   1.285 + * like a locale specification to control the specific behavior of
   1.286 + * the newly instantiated converter.
   1.287 + * The meaning of the options depends on the particular converter.
   1.288 + * If an option is not defined for or recognized by a given converter, then it is ignored.</p>
   1.289 + *
   1.290 + * <p>Options are appended to the converter name string, with a
   1.291 + * <code>UCNV_OPTION_SEP_CHAR</code> between the name and the first option and
   1.292 + * also between adjacent options.</p>
   1.293 + *
   1.294 + * <p>If the alias is ambiguous, then the preferred converter is used
   1.295 + * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.</p>
   1.296 + *
   1.297 + * <p>The conversion behavior and names can vary between platforms. ICU may
   1.298 + * convert some characters differently from other platforms. Details on this topic
   1.299 + * are in the <a href="http://icu.sourceforge.net/userguide/conversion.html">User's
   1.300 + * Guide</a>.</p>
   1.301 + *
   1.302 + * @param converterName Name of the uconv table, may have options appended
   1.303 + * @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>
   1.304 + * @return the created Unicode converter object, or <TT>NULL</TT> if an error occured
   1.305 + * @see ucnv_openU
   1.306 + * @see ucnv_openCCSID
   1.307 + * @see ucnv_close
   1.308 + * @stable ICU 2.0
   1.309 + */
   1.310 +U_STABLE UConverter* U_EXPORT2 
   1.311 +ucnv_open(const char *converterName, UErrorCode *err);
   1.312 +
   1.313 +
   1.314 +/**
   1.315 + * Creates a Unicode converter with the names specified as unicode string. 
   1.316 + * The name should be limited to the ASCII-7 alphanumerics range.
   1.317 + * The actual name will be resolved with the alias file
   1.318 + * using a case-insensitive string comparison that ignores
   1.319 + * the delimiters '-', '_', and ' ' (dash, underscore, and space).
   1.320 + * E.g., the names "UTF8", "utf-8", and "Utf 8" are all equivalent.
   1.321 + * If <TT>NULL</TT> is passed for the converter name, it will create 
   1.322 + * one with the ucnv_getDefaultName() return value.
   1.323 + * If the alias is ambiguous, then the preferred converter is used
   1.324 + * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
   1.325 + * @param name : name of the uconv table in a zero terminated 
   1.326 + *        Unicode string
   1.327 + * @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, 
   1.328 + *        U_FILE_ACCESS_ERROR</TT>
   1.329 + * @return the created Unicode converter object, or <TT>NULL</TT> if an 
   1.330 + *        error occured
   1.331 + * @see ucnv_open
   1.332 + * @see ucnv_openCCSID
   1.333 + * @see ucnv_close
   1.334 + * @see ucnv_getDefaultName
   1.335 + * @stable ICU 2.0
   1.336 + */
   1.337 +U_STABLE UConverter* U_EXPORT2 
   1.338 +ucnv_openU(const UChar *name,
   1.339 +           UErrorCode *err);
   1.340 +
   1.341 +/**
   1.342 + * Creates a UConverter object from a CCSID number and platform pair.
   1.343 + * Note that the usefulness of this function is limited to platforms with numeric
   1.344 + * encoding IDs. Only IBM and Microsoft platforms use numeric (16-bit) identifiers for
   1.345 + * encodings.
   1.346 + *
   1.347 + * In addition, IBM CCSIDs and Unicode conversion tables are not 1:1 related.
   1.348 + * For many IBM CCSIDs there are multiple (up to six) Unicode conversion tables, and
   1.349 + * for some Unicode conversion tables there are multiple CCSIDs.
   1.350 + * Some "alternate" Unicode conversion tables are provided by the
   1.351 + * IBM CDRA conversion table registry.
   1.352 + * The most prominent example of a systematic modification of conversion tables that is
   1.353 + * not provided in the form of conversion table files in the repository is
   1.354 + * that S/390 Unix System Services swaps the codes for Line Feed and New Line in all
   1.355 + * EBCDIC codepages, which requires such a swap in the Unicode conversion tables as well.
   1.356 + *
   1.357 + * Only IBM default conversion tables are accessible with ucnv_openCCSID().
   1.358 + * ucnv_getCCSID() will return the same CCSID for all conversion tables that are associated
   1.359 + * with that CCSID.
   1.360 + *
   1.361 + * Currently, the only "platform" supported in the ICU converter API is UCNV_IBM.
   1.362 + *
   1.363 + * In summary, the use of CCSIDs and the associated API functions is not recommended.
   1.364 + *
   1.365 + * In order to open a converter with the default IBM CDRA Unicode conversion table,
   1.366 + * you can use this function or use the prefix "ibm-":
   1.367 + * \code
   1.368 + *     char name[20];
   1.369 + *     sprintf(name, "ibm-%hu", ccsid);
   1.370 + *     cnv=ucnv_open(name, &errorCode);
   1.371 + * \endcode
   1.372 + *
   1.373 + * In order to open a converter with the IBM S/390 Unix System Services variant
   1.374 + * of a Unicode/EBCDIC conversion table,
   1.375 + * you can use the prefix "ibm-" together with the option string UCNV_SWAP_LFNL_OPTION_STRING:
   1.376 + * \code
   1.377 + *     char name[20];
   1.378 + *     sprintf(name, "ibm-%hu" UCNV_SWAP_LFNL_OPTION_STRING, ccsid);
   1.379 + *     cnv=ucnv_open(name, &errorCode);
   1.380 + * \endcode
   1.381 + *
   1.382 + * In order to open a converter from a Microsoft codepage number, use the prefix "cp":
   1.383 + * \code
   1.384 + *     char name[20];
   1.385 + *     sprintf(name, "cp%hu", codepageID);
   1.386 + *     cnv=ucnv_open(name, &errorCode);
   1.387 + * \endcode
   1.388 + *
   1.389 + * If the alias is ambiguous, then the preferred converter is used
   1.390 + * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
   1.391 + *
   1.392 + * @param codepage codepage number to create
   1.393 + * @param platform the platform in which the codepage number exists
   1.394 + * @param err error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>
   1.395 + * @return the created Unicode converter object, or <TT>NULL</TT> if an error
   1.396 + *   occured.
   1.397 + * @see ucnv_open
   1.398 + * @see ucnv_openU
   1.399 + * @see ucnv_close
   1.400 + * @see ucnv_getCCSID
   1.401 + * @see ucnv_getPlatform
   1.402 + * @see UConverterPlatform
   1.403 + * @stable ICU 2.0
   1.404 + */
   1.405 +U_STABLE UConverter* U_EXPORT2
   1.406 +ucnv_openCCSID(int32_t codepage,
   1.407 +               UConverterPlatform platform,
   1.408 +               UErrorCode * err);
   1.409 +
   1.410 +/**
   1.411 + * <p>Creates a UConverter object specified from a packageName and a converterName.</p>
   1.412 + * 
   1.413 + * <p>The packageName and converterName must point to an ICU udata object, as defined by
   1.414 + *   <code> udata_open( packageName, "cnv", converterName, err) </code> or equivalent.
   1.415 + * Typically, packageName will refer to a (.dat) file, or to a package registered with
   1.416 + * udata_setAppData(). Using a full file or directory pathname for packageName is deprecated.</p>
   1.417 + * 
   1.418 + * <p>The name will NOT be looked up in the alias mechanism, nor will the converter be
   1.419 + * stored in the converter cache or the alias table. The only way to open further converters
   1.420 + * is call this function multiple times, or use the ucnv_safeClone() function to clone a 
   1.421 + * 'master' converter.</p>
   1.422 + *
   1.423 + * <p>A future version of ICU may add alias table lookups and/or caching
   1.424 + * to this function.</p>
   1.425 + * 
   1.426 + * <p>Example Use:
   1.427 + *      <code>cnv = ucnv_openPackage("myapp", "myconverter", &err);</code>
   1.428 + * </p>
   1.429 + *
   1.430 + * @param packageName name of the package (equivalent to 'path' in udata_open() call)
   1.431 + * @param converterName name of the data item to be used, without suffix.
   1.432 + * @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>
   1.433 + * @return the created Unicode converter object, or <TT>NULL</TT> if an error occured
   1.434 + * @see udata_open
   1.435 + * @see ucnv_open
   1.436 + * @see ucnv_safeClone
   1.437 + * @see ucnv_close
   1.438 + * @stable ICU 2.2
   1.439 + */
   1.440 +U_STABLE UConverter* U_EXPORT2 
   1.441 +ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err);
   1.442 +
   1.443 +/**
   1.444 + * Thread safe converter cloning operation.
   1.445 + * For most efficient operation, pass in a stackBuffer (and a *pBufferSize)
   1.446 + * with at least U_CNV_SAFECLONE_BUFFERSIZE bytes of space.
   1.447 + * If the buffer size is sufficient, then the clone will use the stack buffer;
   1.448 + * otherwise, it will be allocated, and *pBufferSize will indicate
   1.449 + * the actual size. (This should not occur with U_CNV_SAFECLONE_BUFFERSIZE.)
   1.450 + *
   1.451 + * You must ucnv_close() the clone in any case.
   1.452 + *
   1.453 + * If *pBufferSize==0, (regardless of whether stackBuffer==NULL or not)
   1.454 + * then *pBufferSize will be changed to a sufficient size
   1.455 + * for cloning this converter,
   1.456 + * without actually cloning the converter ("pure pre-flighting").
   1.457 + *
   1.458 + * If *pBufferSize is greater than zero but not large enough for a stack-based
   1.459 + * clone, then the converter is cloned using newly allocated memory
   1.460 + * and *pBufferSize is changed to the necessary size.
   1.461 + *
   1.462 + * If the converter clone fits into the stack buffer but the stack buffer is not
   1.463 + * sufficiently aligned for the clone, then the clone will use an
   1.464 + * adjusted pointer and use an accordingly smaller buffer size.
   1.465 + *
   1.466 + * @param cnv converter to be cloned
   1.467 + * @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated. 
   1.468 + *  If buffer is not large enough, new memory will be allocated.
   1.469 + *  Clients can use the U_CNV_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations.
   1.470 + * @param pBufferSize pointer to size of allocated space. pBufferSize must not be NULL.
   1.471 + * @param status to indicate whether the operation went on smoothly or there were errors
   1.472 + *  An informational status value, U_SAFECLONE_ALLOCATED_WARNING,
   1.473 + *  is used if any allocations were necessary.
   1.474 + *  However, it is better to check if *pBufferSize grew for checking for
   1.475 + *  allocations because warning codes can be overridden by subsequent
   1.476 + *  function calls.
   1.477 + * @return pointer to the new clone
   1.478 + * @stable ICU 2.0
   1.479 + */
   1.480 +U_STABLE UConverter * U_EXPORT2 
   1.481 +ucnv_safeClone(const UConverter *cnv, 
   1.482 +               void             *stackBuffer,
   1.483 +               int32_t          *pBufferSize, 
   1.484 +               UErrorCode       *status);
   1.485 +
   1.486 +/**
   1.487 + * \def U_CNV_SAFECLONE_BUFFERSIZE
   1.488 + * Definition of a buffer size that is designed to be large enough for
   1.489 + * converters to be cloned with ucnv_safeClone().
   1.490 + * @stable ICU 2.0
   1.491 + */
   1.492 +#define U_CNV_SAFECLONE_BUFFERSIZE  1024
   1.493 +
   1.494 +/**
   1.495 + * Deletes the unicode converter and releases resources associated
   1.496 + * with just this instance.
   1.497 + * Does not free up shared converter tables.
   1.498 + *
   1.499 + * @param converter the converter object to be deleted
   1.500 + * @see ucnv_open
   1.501 + * @see ucnv_openU
   1.502 + * @see ucnv_openCCSID
   1.503 + * @stable ICU 2.0
   1.504 + */
   1.505 +U_STABLE void  U_EXPORT2
   1.506 +ucnv_close(UConverter * converter);
   1.507 +
   1.508 +/**
   1.509 + * Fills in the output parameter, subChars, with the substitution characters
   1.510 + * as multiple bytes.
   1.511 + *
   1.512 + * @param converter the Unicode converter
   1.513 + * @param subChars the subsitution characters
   1.514 + * @param len on input the capacity of subChars, on output the number 
   1.515 + * of bytes copied to it
   1.516 + * @param  err the outgoing error status code.
   1.517 + * If the substitution character array is too small, an
   1.518 + * <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
   1.519 + * @see ucnv_setSubstChars
   1.520 + * @stable ICU 2.0
   1.521 + */
   1.522 +U_STABLE void U_EXPORT2
   1.523 +ucnv_getSubstChars(const UConverter *converter,
   1.524 +                   char *subChars,
   1.525 +                   int8_t *len,
   1.526 +                   UErrorCode *err);
   1.527 +
   1.528 +/**
   1.529 + * Sets the substitution chars when converting from unicode to a codepage. The
   1.530 + * substitution is specified as a string of 1-4 bytes, and may contain
   1.531 + *  <TT>NULL</TT> byte.
   1.532 + * @param converter the Unicode converter
   1.533 + * @param subChars the substitution character byte sequence we want set
   1.534 + * @param len the number of bytes in subChars
   1.535 + * @param err the error status code.  <TT>U_INDEX_OUTOFBOUNDS_ERROR </TT> if
   1.536 + * len is bigger than the maximum number of bytes allowed in subchars
   1.537 + * @see ucnv_getSubstChars
   1.538 + * @stable ICU 2.0
   1.539 + */
   1.540 +U_STABLE void U_EXPORT2
   1.541 +ucnv_setSubstChars(UConverter *converter,
   1.542 +                   const char *subChars,
   1.543 +                   int8_t len,
   1.544 +                   UErrorCode *err);
   1.545 +
   1.546 +/**
   1.547 + * Fills in the output parameter, errBytes, with the error characters from the
   1.548 + * last failing conversion.
   1.549 + *
   1.550 + * @param converter the Unicode converter
   1.551 + * @param errBytes the codepage bytes which were in error
   1.552 + * @param len on input the capacity of errBytes, on output the number of
   1.553 + *  bytes which were copied to it
   1.554 + * @param err the error status code.
   1.555 + * If the substitution character array is too small, an
   1.556 + * <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
   1.557 + * @stable ICU 2.0
   1.558 + */
   1.559 +U_STABLE void U_EXPORT2
   1.560 +ucnv_getInvalidChars(const UConverter *converter,
   1.561 +                     char *errBytes,
   1.562 +                     int8_t *len,
   1.563 +                     UErrorCode *err);
   1.564 +
   1.565 +/**
   1.566 + * Fills in the output parameter, errChars, with the error characters from the
   1.567 + * last failing conversion.
   1.568 + *
   1.569 + * @param converter the Unicode converter
   1.570 + * @param errUChars the UChars which were in error
   1.571 + * @param len on input the capacity of errUChars, on output the number of 
   1.572 + *  UChars which were copied to it
   1.573 + * @param err the error status code.
   1.574 + * If the substitution character array is too small, an
   1.575 + * <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
   1.576 + * @stable ICU 2.0
   1.577 + */
   1.578 +U_STABLE void U_EXPORT2
   1.579 +ucnv_getInvalidUChars(const UConverter *converter,
   1.580 +                      UChar *errUChars,
   1.581 +                      int8_t *len,
   1.582 +                      UErrorCode *err);
   1.583 +
   1.584 +/**
   1.585 + * Resets the state of a converter to the default state. This is used
   1.586 + * in the case of an error, to restart a conversion from a known default state.
   1.587 + * It will also empty the internal output buffers.
   1.588 + * @param converter the Unicode converter
   1.589 + * @stable ICU 2.0
   1.590 + */
   1.591 +U_STABLE void U_EXPORT2
   1.592 +ucnv_reset(UConverter *converter);
   1.593 +
   1.594 +/**
   1.595 + * Resets the to-Unicode part of a converter state to the default state.
   1.596 + * This is used in the case of an error to restart a conversion to
   1.597 + * Unicode to a known default state. It will also empty the internal
   1.598 + * output buffers used for the conversion to Unicode codepoints.
   1.599 + * @param converter the Unicode converter
   1.600 + * @stable ICU 2.0
   1.601 + */
   1.602 +U_STABLE void U_EXPORT2 
   1.603 +ucnv_resetToUnicode(UConverter *converter);
   1.604 +
   1.605 +/**
   1.606 + * Resets the from-Unicode part of a converter state to the default state.
   1.607 + * This is used in the case of an error to restart a conversion from
   1.608 + * Unicode to a known default state. It will also empty the internal output
   1.609 + * buffers used for the conversion from Unicode codepoints.
   1.610 + * @param converter the Unicode converter
   1.611 + * @stable ICU 2.0
   1.612 + */
   1.613 +U_STABLE void U_EXPORT2 
   1.614 +ucnv_resetFromUnicode(UConverter *converter);
   1.615 +
   1.616 +/**
   1.617 + * Returns the maximum number of bytes that are output per UChar in conversion
   1.618 + * from Unicode using this converter.
   1.619 + * The returned number can be used with UCNV_GET_MAX_BYTES_FOR_STRING
   1.620 + * to calculate the size of a target buffer for conversion from Unicode.
   1.621 + *
   1.622 + * Note: Before ICU 2.8, this function did not return reliable numbers for
   1.623 + * some stateful converters (EBCDIC_STATEFUL, ISO-2022) and LMBCS.
   1.624 + *
   1.625 + * This number may not be the same as the maximum number of bytes per
   1.626 + * "conversion unit". In other words, it may not be the intuitively expected
   1.627 + * number of bytes per character that would be published for a charset,
   1.628 + * and may not fulfill any other purpose than the allocation of an output
   1.629 + * buffer of guaranteed sufficient size for a given input length and converter.
   1.630 + *
   1.631 + * Examples for special cases that are taken into account:
   1.632 + * - Supplementary code points may convert to more bytes than BMP code points.
   1.633 + *   This function returns bytes per UChar (UTF-16 code unit), not per
   1.634 + *   Unicode code point, for efficient buffer allocation.
   1.635 + * - State-shifting output (SI/SO, escapes, etc.) from stateful converters.
   1.636 + * - When m input UChars are converted to n output bytes, then the maximum m/n
   1.637 + *   is taken into account.
   1.638 + *
   1.639 + * The number returned here does not take into account
   1.640 + * (see UCNV_GET_MAX_BYTES_FOR_STRING):
   1.641 + * - callbacks which output more than one charset character sequence per call,
   1.642 + *   like escape callbacks
   1.643 + * - initial and final non-character bytes that are output by some converters
   1.644 + *   (automatic BOMs, initial escape sequence, final SI, etc.)
   1.645 + *
   1.646 + * Examples for returned values:
   1.647 + * - SBCS charsets: 1
   1.648 + * - Shift-JIS: 2
   1.649 + * - UTF-16: 2 (2 per BMP, 4 per surrogate _pair_, BOM not counted)
   1.650 + * - UTF-8: 3 (3 per BMP, 4 per surrogate _pair_)
   1.651 + * - EBCDIC_STATEFUL (EBCDIC mixed SBCS/DBCS): 3 (SO + DBCS)
   1.652 + * - ISO-2022: 3 (always outputs UTF-8)
   1.653 + * - ISO-2022-JP: 6 (4-byte escape sequences + DBCS)
   1.654 + * - ISO-2022-CN: 8 (4-byte designator sequences + 2-byte SS2/SS3 + DBCS)
   1.655 + *
   1.656 + * @param converter The Unicode converter.
   1.657 + * @return The maximum number of bytes per UChar that are output by ucnv_fromUnicode(),
   1.658 + *         to be used together with UCNV_GET_MAX_BYTES_FOR_STRING for buffer allocation.
   1.659 + *
   1.660 + * @see UCNV_GET_MAX_BYTES_FOR_STRING
   1.661 + * @see ucnv_getMinCharSize
   1.662 + * @stable ICU 2.0
   1.663 + */
   1.664 +U_STABLE int8_t U_EXPORT2
   1.665 +ucnv_getMaxCharSize(const UConverter *converter);
   1.666 +
   1.667 +#ifndef U_HIDE_DRAFT_API
   1.668 +
   1.669 +/**
   1.670 + * Calculates the size of a buffer for conversion from Unicode to a charset.
   1.671 + * The calculated size is guaranteed to be sufficient for this conversion.
   1.672 + *
   1.673 + * It takes into account initial and final non-character bytes that are output
   1.674 + * by some converters.
   1.675 + * It does not take into account callbacks which output more than one charset
   1.676 + * character sequence per call, like escape callbacks.
   1.677 + * The default (substitution) callback only outputs one charset character sequence.
   1.678 + *
   1.679 + * @param length Number of UChars to be converted.
   1.680 + * @param maxCharSize Return value from ucnv_getMaxCharSize() for the converter
   1.681 + *                    that will be used.
   1.682 + * @return Size of a buffer that will be large enough to hold the output bytes of
   1.683 + *         converting length UChars with the converter that returned the maxCharSize.
   1.684 + *
   1.685 + * @see ucnv_getMaxCharSize
   1.686 + * @stable ICU 2.8
   1.687 + */
   1.688 +#define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \
   1.689 +     (((int32_t)(length)+10)*(int32_t)(maxCharSize))
   1.690 +
   1.691 +#endif /*U_HIDE_DRAFT_API*/
   1.692 +
   1.693 +/**
   1.694 + * Returns the minimum byte length for characters in this codepage. 
   1.695 + * This is usually either 1 or 2.
   1.696 + * @param converter the Unicode converter
   1.697 + * @return the minimum number of bytes allowed by this particular converter
   1.698 + * @see ucnv_getMaxCharSize
   1.699 + * @stable ICU 2.0
   1.700 + */
   1.701 +U_STABLE int8_t U_EXPORT2
   1.702 +ucnv_getMinCharSize(const UConverter *converter);
   1.703 +
   1.704 +/**
   1.705 + * Returns the display name of the converter passed in based on the Locale 
   1.706 + * passed in. If the locale contains no display name, the internal ASCII
   1.707 + * name will be filled in.
   1.708 + *
   1.709 + * @param converter the Unicode converter.
   1.710 + * @param displayLocale is the specific Locale we want to localised for
   1.711 + * @param displayName user provided buffer to be filled in
   1.712 + * @param displayNameCapacity size of displayName Buffer
   1.713 + * @param err error status code
   1.714 + * @return displayNameLength number of UChar needed in displayName
   1.715 + * @see ucnv_getName
   1.716 + * @stable ICU 2.0
   1.717 + */
   1.718 +U_STABLE int32_t U_EXPORT2
   1.719 +ucnv_getDisplayName(const UConverter *converter,
   1.720 +                    const char *displayLocale,
   1.721 +                    UChar *displayName,
   1.722 +                    int32_t displayNameCapacity,
   1.723 +                    UErrorCode *err);
   1.724 +
   1.725 +/**
   1.726 + * Gets the internal, canonical name of the converter (zero-terminated).
   1.727 + * The lifetime of the returned string will be that of the converter 
   1.728 + * passed to this function.
   1.729 + * @param converter the Unicode converter
   1.730 + * @param err UErrorCode status
   1.731 + * @return the internal name of the converter
   1.732 + * @see ucnv_getDisplayName
   1.733 + * @stable ICU 2.0
   1.734 + */
   1.735 +U_STABLE const char * U_EXPORT2 
   1.736 +ucnv_getName(const UConverter *converter, UErrorCode *err);
   1.737 +
   1.738 +/**
   1.739 + * Gets a codepage number associated with the converter. This is not guaranteed
   1.740 + * to be the one used to create the converter. Some converters do not represent
   1.741 + * platform registered codepages and return zero for the codepage number.
   1.742 + * The error code fill-in parameter indicates if the codepage number
   1.743 + * is available.
   1.744 + * Does not check if the converter is <TT>NULL</TT> or if converter's data
   1.745 + * table is <TT>NULL</TT>.
   1.746 + *
   1.747 + * Important: The use of CCSIDs is not recommended because it is limited
   1.748 + * to only two platforms in principle and only one (UCNV_IBM) in the current
   1.749 + * ICU converter API.
   1.750 + * Also, CCSIDs are insufficient to identify IBM Unicode conversion tables precisely.
   1.751 + * For more details see ucnv_openCCSID().
   1.752 + *
   1.753 + * @param converter the Unicode converter
   1.754 + * @param err the error status code.
   1.755 + * @return If any error occurrs, -1 will be returned otherwise, the codepage number
   1.756 + * will be returned
   1.757 + * @see ucnv_openCCSID
   1.758 + * @see ucnv_getPlatform
   1.759 + * @stable ICU 2.0
   1.760 + */
   1.761 +U_STABLE int32_t U_EXPORT2
   1.762 +ucnv_getCCSID(const UConverter *converter,
   1.763 +              UErrorCode *err);
   1.764 +
   1.765 +/**
   1.766 + * Gets a codepage platform associated with the converter. Currently, 
   1.767 + * only <TT>UCNV_IBM</TT> will be returned.
   1.768 + * Does not test if the converter is <TT>NULL</TT> or if converter's data 
   1.769 + * table is <TT>NULL</TT>. 
   1.770 + * @param converter the Unicode converter
   1.771 + * @param err the error status code.
   1.772 + * @return The codepage platform
   1.773 + * @stable ICU 2.0
   1.774 + */
   1.775 +U_STABLE UConverterPlatform U_EXPORT2
   1.776 +ucnv_getPlatform(const UConverter *converter,
   1.777 +                 UErrorCode *err);
   1.778 +
   1.779 +/**
   1.780 + * Gets the type of the converter
   1.781 + * e.g. SBCS, MBCS, DBCS, UTF8, UTF16_BE, UTF16_LE, ISO_2022, 
   1.782 + * EBCDIC_STATEFUL, LATIN_1
   1.783 + * @param converter a valid, opened converter
   1.784 + * @return the type of the converter
   1.785 + * @stable ICU 2.0
   1.786 + */
   1.787 +U_STABLE UConverterType U_EXPORT2
   1.788 +ucnv_getType(const UConverter * converter);
   1.789 +
   1.790 +/**
   1.791 + * Gets the "starter" (lead) bytes for converters of type MBCS.
   1.792 + * Will fill in an <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> if converter passed in
   1.793 + * is not MBCS. Fills in an array of type UBool, with the value of the byte 
   1.794 + * as offset to the array. For example, if (starters[0x20] == TRUE) at return,
   1.795 + * it means that the byte 0x20 is a starter byte in this converter.
   1.796 + * Context pointers are always owned by the caller.
   1.797 + * 
   1.798 + * @param converter a valid, opened converter of type MBCS
   1.799 + * @param starters an array of size 256 to be filled in
   1.800 + * @param err error status, <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> if the 
   1.801 + * converter is not a type which can return starters.
   1.802 + * @see ucnv_getType
   1.803 + * @stable ICU 2.0
   1.804 + */
   1.805 +U_STABLE void U_EXPORT2
   1.806 +ucnv_getStarters(const UConverter* converter, 
   1.807 +                 UBool starters[256],
   1.808 +                 UErrorCode* err);
   1.809 +
   1.810 +
   1.811 +/**
   1.812 + * Selectors for Unicode sets that can be returned by ucnv_getUnicodeSet().
   1.813 + * @see ucnv_getUnicodeSet
   1.814 + * @stable ICU 2.6
   1.815 + */
   1.816 +typedef enum UConverterUnicodeSet {
   1.817 +    /** Select the set of roundtrippable Unicode code points. @stable ICU 2.6 */
   1.818 +    UCNV_ROUNDTRIP_SET,
   1.819 +    /** Number of UConverterUnicodeSet selectors. @stable ICU 2.6 */
   1.820 +    UCNV_SET_COUNT
   1.821 +} UConverterUnicodeSet;
   1.822 +
   1.823 +
   1.824 +/**
   1.825 + * Returns the set of Unicode code points that can be converted by an ICU converter.
   1.826 + *
   1.827 + * The current implementation returns only one kind of set (UCNV_ROUNDTRIP_SET):
   1.828 + * The set of all Unicode code points that can be roundtrip-converted
   1.829 + * (converted without any data loss) with the converter.
   1.830 + * This set will not include code points that have fallback mappings
   1.831 + * or are only the result of reverse fallback mappings.
   1.832 + * See UTR #22 "Character Mapping Markup Language"
   1.833 + * at http://www.unicode.org/reports/tr22/
   1.834 + *
   1.835 + * This is useful for example for
   1.836 + * - checking that a string or document can be roundtrip-converted with a converter,
   1.837 + *   without/before actually performing the conversion
   1.838 + * - testing if a converter can be used for text for typical text for a certain locale,
   1.839 + *   by comparing its roundtrip set with the set of ExemplarCharacters from
   1.840 + *   ICU's locale data or other sources
   1.841 + *
   1.842 + * In the future, there may be more UConverterUnicodeSet choices to select
   1.843 + * sets with different properties.
   1.844 + *
   1.845 + * @param cnv The converter for which a set is requested.
   1.846 + * @param setFillIn A valid USet *. It will be cleared by this function before
   1.847 + *            the converter's specific set is filled into the USet.
   1.848 + * @param whichSet A UConverterUnicodeSet selector;
   1.849 + *              currently UCNV_ROUNDTRIP_SET is the only supported value.
   1.850 + * @param pErrorCode ICU error code in/out parameter.
   1.851 + *                   Must fulfill U_SUCCESS before the function call.
   1.852 + *
   1.853 + * @see UConverterUnicodeSet
   1.854 + * @see uset_open
   1.855 + * @see uset_close
   1.856 + * @stable ICU 2.6
   1.857 + */
   1.858 +U_STABLE void U_EXPORT2
   1.859 +ucnv_getUnicodeSet(const UConverter *cnv,
   1.860 +                   USet *setFillIn,
   1.861 +                   UConverterUnicodeSet whichSet,
   1.862 +                   UErrorCode *pErrorCode);
   1.863 +
   1.864 +/**
   1.865 + * Gets the current calback function used by the converter when an illegal
   1.866 + *  or invalid codepage sequence is found. 
   1.867 + * Context pointers are always owned by the caller.
   1.868 + *
   1.869 + * @param converter the unicode converter
   1.870 + * @param action fillin: returns the callback function pointer
   1.871 + * @param context fillin: returns the callback's private void* context
   1.872 + * @see ucnv_setToUCallBack
   1.873 + * @stable ICU 2.0
   1.874 + */
   1.875 +U_STABLE void U_EXPORT2
   1.876 +ucnv_getToUCallBack (const UConverter * converter,
   1.877 +                     UConverterToUCallback *action,
   1.878 +                     const void **context);
   1.879 +
   1.880 +/**
   1.881 + * Gets the current callback function used by the converter when illegal 
   1.882 + * or invalid Unicode sequence is found.
   1.883 + * Context pointers are always owned by the caller.
   1.884 + *
   1.885 + * @param converter the unicode converter
   1.886 + * @param action fillin: returns the callback function pointer
   1.887 + * @param context fillin: returns the callback's private void* context
   1.888 + * @see ucnv_setFromUCallBack
   1.889 + * @stable ICU 2.0
   1.890 + */
   1.891 +U_STABLE void U_EXPORT2
   1.892 +ucnv_getFromUCallBack (const UConverter * converter,
   1.893 +                       UConverterFromUCallback *action,
   1.894 +                       const void **context);
   1.895 +
   1.896 +/**
   1.897 + * Changes the callback function used by the converter when
   1.898 + * an illegal or invalid sequence is found.
   1.899 + * Context pointers are always owned by the caller.
   1.900 + * Predefined actions and contexts can be found in the ucnv_err.h header.
   1.901 + *
   1.902 + * @param converter the unicode converter
   1.903 + * @param newAction the new callback function
   1.904 + * @param newContext the new toUnicode callback context pointer. This can be NULL.
   1.905 + * @param oldAction fillin: returns the old callback function pointer. This can be NULL.
   1.906 + * @param oldContext fillin: returns the old callback's private void* context. This can be NULL.
   1.907 + * @param err The error code status
   1.908 + * @see ucnv_getToUCallBack
   1.909 + * @stable ICU 2.0
   1.910 + */
   1.911 +U_STABLE void U_EXPORT2
   1.912 +ucnv_setToUCallBack (UConverter * converter,
   1.913 +                     UConverterToUCallback newAction,
   1.914 +                     const void* newContext,
   1.915 +                     UConverterToUCallback *oldAction,
   1.916 +                     const void** oldContext,
   1.917 +                     UErrorCode * err);
   1.918 +
   1.919 +/**
   1.920 + * Changes the current callback function used by the converter when
   1.921 + * an illegal or invalid sequence is found.
   1.922 + * Context pointers are always owned by the caller.
   1.923 + * Predefined actions and contexts can be found in the ucnv_err.h header.
   1.924 + *
   1.925 + * @param converter the unicode converter
   1.926 + * @param newAction the new callback function
   1.927 + * @param newContext the new fromUnicode callback context pointer. This can be NULL.
   1.928 + * @param oldAction fillin: returns the old callback function pointer. This can be NULL.
   1.929 + * @param oldContext fillin: returns the old callback's private void* context. This can be NULL.
   1.930 + * @param err The error code status
   1.931 + * @see ucnv_getFromUCallBack
   1.932 + * @stable ICU 2.0
   1.933 + */
   1.934 +U_STABLE void U_EXPORT2
   1.935 +ucnv_setFromUCallBack (UConverter * converter,
   1.936 +                       UConverterFromUCallback newAction,
   1.937 +                       const void *newContext,
   1.938 +                       UConverterFromUCallback *oldAction,
   1.939 +                       const void **oldContext,
   1.940 +                       UErrorCode * err);
   1.941 +
   1.942 +/**
   1.943 + * Converts an array of unicode characters to an array of codepage
   1.944 + * characters. This function is optimized for converting a continuous
   1.945 + * stream of data in buffer-sized chunks, where the entire source and
   1.946 + * target does not fit in available buffers.
   1.947 + * 
   1.948 + * The source pointer is an in/out parameter. It starts out pointing where the 
   1.949 + * conversion is to begin, and ends up pointing after the last UChar consumed. 
   1.950 + * 
   1.951 + * Target similarly starts out pointer at the first available byte in the output
   1.952 + * buffer, and ends up pointing after the last byte written to the output.
   1.953 + * 
   1.954 + * The converter always attempts to consume the entire source buffer, unless 
   1.955 + * (1.) the target buffer is full, or (2.) a failing error is returned from the
   1.956 + * current callback function.  When a successful error status has been
   1.957 + * returned, it means that all of the source buffer has been
   1.958 + *  consumed. At that point, the caller should reset the source and
   1.959 + *  sourceLimit pointers to point to the next chunk.
   1.960 + * 
   1.961 + * At the end of the stream (flush==TRUE), the input is completely consumed
   1.962 + * when *source==sourceLimit and no error code is set.
   1.963 + * The converter object is then automatically reset by this function.
   1.964 + * (This means that a converter need not be reset explicitly between data
   1.965 + * streams if it finishes the previous stream without errors.)
   1.966 + * 
   1.967 + * This is a <I>stateful</I> conversion. Additionally, even when all source data has
   1.968 + * been consumed, some data may be in the converters' internal state.
   1.969 + * Call this function repeatedly, updating the target pointers with
   1.970 + * the next empty chunk of target in case of a
   1.971 + * <TT>U_BUFFER_OVERFLOW_ERROR</TT>, and updating the source  pointers
   1.972 + *  with the next chunk of source when a successful error status is
   1.973 + * returned, until there are no more chunks of source data.
   1.974 + * @param converter the Unicode converter
   1.975 + * @param target I/O parameter. Input : Points to the beginning of the buffer to copy
   1.976 + *  codepage characters to. Output : points to after the last codepage character copied
   1.977 + *  to <TT>target</TT>.
   1.978 + * @param targetLimit the pointer just after last of the <TT>target</TT> buffer
   1.979 + * @param source I/O parameter, pointer to pointer to the source Unicode character buffer. 
   1.980 + * @param sourceLimit the pointer just after the last of the source buffer
   1.981 + * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number
   1.982 + * of allocated cells as <TT>target</TT>. Will fill in offsets from target to source pointer
   1.983 + * e.g: <TT>offsets[3]</TT> is equal to 6, it means that the <TT>target[3]</TT> was a result of transcoding <TT>source[6]</TT>
   1.984 + * For output data carried across calls, and other data without a specific source character
   1.985 + * (such as from escape sequences or callbacks)  -1 will be placed for offsets. 
   1.986 + * @param flush set to <TT>TRUE</TT> if the current source buffer is the last available
   1.987 + * chunk of the source, <TT>FALSE</TT> otherwise. Note that if a failing status is returned,
   1.988 + * this function may have to be called multiple times with flush set to <TT>TRUE</TT> until
   1.989 + * the source buffer is consumed.
   1.990 + * @param err the error status.  <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> will be set if the
   1.991 + * converter is <TT>NULL</TT>.
   1.992 + * <code>U_BUFFER_OVERFLOW_ERROR</code> will be set if the target is full and there is 
   1.993 + * still data to be written to the target.
   1.994 + * @see ucnv_fromUChars
   1.995 + * @see ucnv_convert
   1.996 + * @see ucnv_getMinCharSize
   1.997 + * @see ucnv_setToUCallBack
   1.998 + * @stable ICU 2.0
   1.999 + */
  1.1000 +U_STABLE void U_EXPORT2 
  1.1001 +ucnv_fromUnicode (UConverter * converter,
  1.1002 +                  char **target,
  1.1003 +                  const char *targetLimit,
  1.1004 +                  const UChar ** source,
  1.1005 +                  const UChar * sourceLimit,
  1.1006 +                  int32_t* offsets,
  1.1007 +                  UBool flush,
  1.1008 +                  UErrorCode * err);
  1.1009 +
  1.1010 +/**
  1.1011 + * Converts a buffer of codepage bytes into an array of unicode UChars
  1.1012 + * characters. This function is optimized for converting a continuous
  1.1013 + * stream of data in buffer-sized chunks, where the entire source and
  1.1014 + * target does not fit in available buffers.
  1.1015 + * 
  1.1016 + * The source pointer is an in/out parameter. It starts out pointing where the 
  1.1017 + * conversion is to begin, and ends up pointing after the last byte of source consumed. 
  1.1018 + * 
  1.1019 + * Target similarly starts out pointer at the first available UChar in the output
  1.1020 + * buffer, and ends up pointing after the last UChar written to the output. 
  1.1021 + * It does NOT necessarily keep UChar sequences together.
  1.1022 + * 
  1.1023 + * The converter always attempts to consume the entire source buffer, unless 
  1.1024 + * (1.) the target buffer is full, or (2.) a failing error is returned from the
  1.1025 + * current callback function.  When a successful error status has been
  1.1026 + * returned, it means that all of the source buffer has been
  1.1027 + *  consumed. At that point, the caller should reset the source and
  1.1028 + *  sourceLimit pointers to point to the next chunk.
  1.1029 + *
  1.1030 + * At the end of the stream (flush==TRUE), the input is completely consumed
  1.1031 + * when *source==sourceLimit and no error code is set
  1.1032 + * The converter object is then automatically reset by this function.
  1.1033 + * (This means that a converter need not be reset explicitly between data
  1.1034 + * streams if it finishes the previous stream without errors.)
  1.1035 + * 
  1.1036 + * This is a <I>stateful</I> conversion. Additionally, even when all source data has
  1.1037 + * been consumed, some data may be in the converters' internal state.
  1.1038 + * Call this function repeatedly, updating the target pointers with
  1.1039 + * the next empty chunk of target in case of a
  1.1040 + * <TT>U_BUFFER_OVERFLOW_ERROR</TT>, and updating the source  pointers
  1.1041 + *  with the next chunk of source when a successful error status is
  1.1042 + * returned, until there are no more chunks of source data.
  1.1043 + * @param converter the Unicode converter
  1.1044 + * @param target I/O parameter. Input : Points to the beginning of the buffer to copy
  1.1045 + *  UChars into. Output : points to after the last UChar copied.
  1.1046 + * @param targetLimit the pointer just after the end of the <TT>target</TT> buffer
  1.1047 + * @param source I/O parameter, pointer to pointer to the source codepage buffer. 
  1.1048 + * @param sourceLimit the pointer to the byte after the end of the source buffer
  1.1049 + * @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number
  1.1050 + * of allocated cells as <TT>target</TT>. Will fill in offsets from target to source pointer
  1.1051 + * e.g: <TT>offsets[3]</TT> is equal to 6, it means that the <TT>target[3]</TT> was a result of transcoding <TT>source[6]</TT>
  1.1052 + * For output data carried across calls, and other data without a specific source character
  1.1053 + * (such as from escape sequences or callbacks)  -1 will be placed for offsets. 
  1.1054 + * @param flush set to <TT>TRUE</TT> if the current source buffer is the last available
  1.1055 + * chunk of the source, <TT>FALSE</TT> otherwise. Note that if a failing status is returned,
  1.1056 + * this function may have to be called multiple times with flush set to <TT>TRUE</TT> until
  1.1057 + * the source buffer is consumed.
  1.1058 + * @param err the error status.  <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> will be set if the
  1.1059 + * converter is <TT>NULL</TT>.
  1.1060 + * <code>U_BUFFER_OVERFLOW_ERROR</code> will be set if the target is full and there is 
  1.1061 + * still data to be written to the target. 
  1.1062 + * @see ucnv_fromUChars
  1.1063 + * @see ucnv_convert
  1.1064 + * @see ucnv_getMinCharSize
  1.1065 + * @see ucnv_setFromUCallBack
  1.1066 + * @see ucnv_getNextUChar
  1.1067 + * @stable ICU 2.0
  1.1068 + */
  1.1069 +U_STABLE void U_EXPORT2 
  1.1070 +ucnv_toUnicode(UConverter *converter,
  1.1071 +               UChar **target,
  1.1072 +               const UChar *targetLimit,
  1.1073 +               const char **source,
  1.1074 +               const char *sourceLimit,
  1.1075 +               int32_t *offsets,
  1.1076 +               UBool flush,
  1.1077 +               UErrorCode *err);
  1.1078 +
  1.1079 +/**
  1.1080 + * Convert the Unicode string into a codepage string using an existing UConverter.
  1.1081 + * The output string is NUL-terminated if possible.
  1.1082 + *
  1.1083 + * This function is a more convenient but less powerful version of ucnv_fromUnicode().
  1.1084 + * It is only useful for whole strings, not for streaming conversion.
  1.1085 + *
  1.1086 + * The maximum output buffer capacity required (barring output from callbacks) will be
  1.1087 + * UCNV_GET_MAX_BYTES_FOR_STRING(srcLength, ucnv_getMaxCharSize(cnv)).
  1.1088 + *
  1.1089 + * @param cnv the converter object to be used (ucnv_resetFromUnicode() will be called)
  1.1090 + * @param src the input Unicode string
  1.1091 + * @param srcLength the input string length, or -1 if NUL-terminated
  1.1092 + * @param dest destination string buffer, can be NULL if destCapacity==0
  1.1093 + * @param destCapacity the number of chars available at dest
  1.1094 + * @param pErrorCode normal ICU error code;
  1.1095 + *                  common error codes that may be set by this function include
  1.1096 + *                  U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING,
  1.1097 + *                  U_ILLEGAL_ARGUMENT_ERROR, and conversion errors
  1.1098 + * @return the length of the output string, not counting the terminating NUL;
  1.1099 + *         if the length is greater than destCapacity, then the string will not fit
  1.1100 + *         and a buffer of the indicated length would need to be passed in
  1.1101 + * @see ucnv_fromUnicode
  1.1102 + * @see ucnv_convert
  1.1103 + * @see UCNV_GET_MAX_BYTES_FOR_STRING
  1.1104 + * @stable ICU 2.0
  1.1105 + */
  1.1106 +U_STABLE int32_t U_EXPORT2
  1.1107 +ucnv_fromUChars(UConverter *cnv,
  1.1108 +                char *dest, int32_t destCapacity,
  1.1109 +                const UChar *src, int32_t srcLength,
  1.1110 +                UErrorCode *pErrorCode);
  1.1111 +
  1.1112 +/**
  1.1113 + * Convert the codepage string into a Unicode string using an existing UConverter.
  1.1114 + * The output string is NUL-terminated if possible.
  1.1115 + *
  1.1116 + * This function is a more convenient but less powerful version of ucnv_toUnicode().
  1.1117 + * It is only useful for whole strings, not for streaming conversion.
  1.1118 + *
  1.1119 + * The maximum output buffer capacity required (barring output from callbacks) will be
  1.1120 + * 2*srcLength (each char may be converted into a surrogate pair).
  1.1121 + *
  1.1122 + * @param cnv the converter object to be used (ucnv_resetToUnicode() will be called)
  1.1123 + * @param src the input codepage string
  1.1124 + * @param srcLength the input string length, or -1 if NUL-terminated
  1.1125 + * @param dest destination string buffer, can be NULL if destCapacity==0
  1.1126 + * @param destCapacity the number of UChars available at dest
  1.1127 + * @param pErrorCode normal ICU error code;
  1.1128 + *                  common error codes that may be set by this function include
  1.1129 + *                  U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING,
  1.1130 + *                  U_ILLEGAL_ARGUMENT_ERROR, and conversion errors
  1.1131 + * @return the length of the output string, not counting the terminating NUL;
  1.1132 + *         if the length is greater than destCapacity, then the string will not fit
  1.1133 + *         and a buffer of the indicated length would need to be passed in
  1.1134 + * @see ucnv_toUnicode
  1.1135 + * @see ucnv_convert
  1.1136 + * @stable ICU 2.0
  1.1137 + */
  1.1138 +U_STABLE int32_t U_EXPORT2
  1.1139 +ucnv_toUChars(UConverter *cnv,
  1.1140 +              UChar *dest, int32_t destCapacity,
  1.1141 +              const char *src, int32_t srcLength,
  1.1142 +              UErrorCode *pErrorCode);
  1.1143 +
  1.1144 +/**
  1.1145 + * Convert a codepage buffer into Unicode one character at a time.
  1.1146 + * The input is completely consumed when the U_INDEX_OUTOFBOUNDS_ERROR is set.
  1.1147 + *
  1.1148 + * Advantage compared to ucnv_toUnicode() or ucnv_toUChars():
  1.1149 + * - Faster for small amounts of data, for most converters, e.g.,
  1.1150 + *   US-ASCII, ISO-8859-1, UTF-8/16/32, and most "normal" charsets.
  1.1151 + *   (For complex converters, e.g., SCSU, UTF-7 and ISO 2022 variants,
  1.1152 + *    it uses ucnv_toUnicode() internally.)
  1.1153 + * - Convenient.
  1.1154 + *
  1.1155 + * Limitations compared to ucnv_toUnicode():
  1.1156 + * - Always assumes flush=TRUE.
  1.1157 + *   This makes ucnv_getNextUChar() unsuitable for "streaming" conversion,
  1.1158 + *   that is, for where the input is supplied in multiple buffers,
  1.1159 + *   because ucnv_getNextUChar() will assume the end of the input at the end
  1.1160 + *   of the first buffer.
  1.1161 + * - Does not provide offset output.
  1.1162 + *
  1.1163 + * It is possible to "mix" ucnv_getNextUChar() and ucnv_toUnicode() because
  1.1164 + * ucnv_getNextUChar() uses the current state of the converter
  1.1165 + * (unlike ucnv_toUChars() which always resets first).
  1.1166 + * However, if ucnv_getNextUChar() is called after ucnv_toUnicode()
  1.1167 + * stopped in the middle of a character sequence (with flush=FALSE),
  1.1168 + * then ucnv_getNextUChar() will always use the slower ucnv_toUnicode()
  1.1169 + * internally until the next character boundary.
  1.1170 + * (This is new in ICU 2.6. In earlier releases, ucnv_getNextUChar() had to
  1.1171 + * start at a character boundary.)
  1.1172 + *
  1.1173 + * Instead of using ucnv_getNextUChar(), it is recommended
  1.1174 + * to convert using ucnv_toUnicode() or ucnv_toUChars()
  1.1175 + * and then iterate over the text using U16_NEXT() or a UCharIterator (uiter.h)
  1.1176 + * or a C++ CharacterIterator or similar.
  1.1177 + * This allows streaming conversion and offset output, for example.
  1.1178 + *
  1.1179 + * <p>Handling of surrogate pairs and supplementary-plane code points:<br>
  1.1180 + * There are two different kinds of codepages that provide mappings for surrogate characters:
  1.1181 + * <ul>
  1.1182 + *   <li>Codepages like UTF-8, UTF-32, and GB 18030 provide direct representations for Unicode
  1.1183 + *       code points U+10000-U+10ffff as well as for single surrogates U+d800-U+dfff.
  1.1184 + *       Each valid sequence will result in exactly one returned code point.
  1.1185 + *       If a sequence results in a single surrogate, then that will be returned
  1.1186 + *       by itself, even if a neighboring sequence encodes the matching surrogate.</li>
  1.1187 + *   <li>Codepages like SCSU and LMBCS (and UTF-16) provide direct representations only for BMP code points
  1.1188 + *       including surrogates. Code points in supplementary planes are represented with
  1.1189 + *       two sequences, each encoding a surrogate.
  1.1190 + *       For these codepages, matching pairs of surrogates will be combined into single
  1.1191 + *       code points for returning from this function.
  1.1192 + *       (Note that SCSU is actually a mix of these codepage types.)</li>
  1.1193 + * </ul></p>
  1.1194 + *
  1.1195 + * @param converter an open UConverter
  1.1196 + * @param source the address of a pointer to the codepage buffer, will be
  1.1197 + *  updated to point after the bytes consumed in the conversion call.
  1.1198 + * @param sourceLimit points to the end of the input buffer
  1.1199 + * @param err fills in error status (see ucnv_toUnicode)
  1.1200 + * <code>U_INDEX_OUTOFBOUNDS_ERROR</code> will be set if the input 
  1.1201 + * is empty or does not convert to any output (e.g.: pure state-change 
  1.1202 + * codes SI/SO, escape sequences for ISO 2022,
  1.1203 + * or if the callback did not output anything, ...).
  1.1204 + * This function will not set a <code>U_BUFFER_OVERFLOW_ERROR</code> because
  1.1205 + *  the "buffer" is the return code. However, there might be subsequent output
  1.1206 + *  stored in the converter object
  1.1207 + * that will be returned in following calls to this function.
  1.1208 + * @return a UChar32 resulting from the partial conversion of source
  1.1209 + * @see ucnv_toUnicode
  1.1210 + * @see ucnv_toUChars
  1.1211 + * @see ucnv_convert
  1.1212 + * @stable ICU 2.0
  1.1213 + */
  1.1214 +U_STABLE UChar32 U_EXPORT2
  1.1215 +ucnv_getNextUChar(UConverter * converter,
  1.1216 +                  const char **source,
  1.1217 +                  const char * sourceLimit,
  1.1218 +                  UErrorCode * err);
  1.1219 +
  1.1220 +/**
  1.1221 + * Convert from one external charset to another using two existing UConverters.
  1.1222 + * Internally, two conversions - ucnv_toUnicode() and ucnv_fromUnicode() -
  1.1223 + * are used, "pivoting" through 16-bit Unicode.
  1.1224 + *
  1.1225 + * There is a similar function, ucnv_convert(),
  1.1226 + * which has the following limitations:
  1.1227 + * - it takes charset names, not converter objects, so that
  1.1228 + *   - two converters are opened for each call
  1.1229 + *   - only single-string conversion is possible, not streaming operation
  1.1230 + * - it does not provide enough information to find out,
  1.1231 + *   in case of failure, whether the toUnicode or
  1.1232 + *   the fromUnicode conversion failed
  1.1233 + *
  1.1234 + * By contrast, ucnv_convertEx()
  1.1235 + * - takes UConverter parameters instead of charset names
  1.1236 + * - fully exposes the pivot buffer for complete error handling
  1.1237 + *
  1.1238 + * ucnv_convertEx() also provides further convenience:
  1.1239 + * - an option to reset the converters at the beginning
  1.1240 + *   (if reset==TRUE, see parameters;
  1.1241 + *    also sets *pivotTarget=*pivotSource=pivotStart)
  1.1242 + * - allow NUL-terminated input
  1.1243 + *   (only a single NUL byte, will not work for charsets with multi-byte NULs)
  1.1244 + *   (if sourceLimit==NULL, see parameters)
  1.1245 + * - terminate with a NUL on output
  1.1246 + *   (only a single NUL byte, not useful for charsets with multi-byte NULs),
  1.1247 + *   or set U_STRING_NOT_TERMINATED_WARNING if the output exactly fills
  1.1248 + *   the target buffer
  1.1249 + * - the pivot buffer can be provided internally;
  1.1250 + *   in this case, the caller will not be able to get details about where an
  1.1251 + *   error occurred
  1.1252 + *   (if pivotStart==NULL, see below)
  1.1253 + *
  1.1254 + * The function returns when one of the following is true:
  1.1255 + * - the entire source text has been converted successfully to the target buffer
  1.1256 + * - a target buffer overflow occurred (U_BUFFER_OVERFLOW_ERROR)
  1.1257 + * - a conversion error occurred
  1.1258 + *   (other U_FAILURE(), see description of pErrorCode)
  1.1259 + *
  1.1260 + * Limitation compared to the direct use of
  1.1261 + * ucnv_fromUnicode() and ucnv_toUnicode():
  1.1262 + * ucnv_convertEx() does not provide offset information.
  1.1263 + *
  1.1264 + * Limitation compared to ucnv_fromUChars() and ucnv_toUChars():
  1.1265 + * ucnv_convertEx() does not support preflighting directly.
  1.1266 + *
  1.1267 + * Sample code for converting a single string from
  1.1268 + * one external charset to UTF-8, ignoring the location of errors:
  1.1269 + *
  1.1270 + * \code
  1.1271 + * int32_t
  1.1272 + * myToUTF8(UConverter *cnv,
  1.1273 + *          const char *s, int32_t length,
  1.1274 + *          char *u8, int32_t capacity,
  1.1275 + *          UErrorCode *pErrorCode) {
  1.1276 + *     UConverter *utf8Cnv;
  1.1277 + *     char *target;
  1.1278 + *
  1.1279 + *     if(U_FAILURE(*pErrorCode)) {
  1.1280 + *         return 0;
  1.1281 + *     }
  1.1282 + *
  1.1283 + *     utf8Cnv=myGetCachedUTF8Converter(pErrorCode);
  1.1284 + *     if(U_FAILURE(*pErrorCode)) {
  1.1285 + *         return 0;
  1.1286 + *     }
  1.1287 + *
  1.1288 + *     target=u8;
  1.1289 + *     ucnv_convertEx(cnv, utf8Cnv,
  1.1290 + *                    &target, u8+capacity,
  1.1291 + *                    &s, length>=0 ? s+length : NULL,
  1.1292 + *                    NULL, NULL, NULL, NULL,
  1.1293 + *                    TRUE, TRUE,
  1.1294 + *                    pErrorCode);
  1.1295 + * 
  1.1296 + *     myReleaseCachedUTF8Converter(utf8Cnv);
  1.1297 + *
  1.1298 + *     // return the output string length, but without preflighting
  1.1299 + *     return (int32_t)(target-u8);
  1.1300 + * }
  1.1301 + * \endcode
  1.1302 + *
  1.1303 + * @param targetCnv     Output converter, used to convert from the UTF-16 pivot
  1.1304 + *                      to the target using ucnv_fromUnicode().
  1.1305 + * @param sourceCnv     Input converter, used to convert from the source to
  1.1306 + *                      the UTF-16 pivot using ucnv_toUnicode().
  1.1307 + * @param target        I/O parameter, same as for ucnv_fromUChars().
  1.1308 + *                      Input: *target points to the beginning of the target buffer.
  1.1309 + *                      Output: *target points to the first unit after the last char written.
  1.1310 + * @param targetLimit   Pointer to the first unit after the target buffer.
  1.1311 + * @param source        I/O parameter, same as for ucnv_toUChars().
  1.1312 + *                      Input: *source points to the beginning of the source buffer.
  1.1313 + *                      Output: *source points to the first unit after the last char read.
  1.1314 + * @param sourceLimit   Pointer to the first unit after the source buffer.
  1.1315 + * @param pivotStart    Pointer to the UTF-16 pivot buffer. If pivotStart==NULL,
  1.1316 + *                      then an internal buffer is used and the other pivot
  1.1317 + *                      arguments are ignored and can be NULL as well.
  1.1318 + * @param pivotSource   I/O parameter, same as source in ucnv_fromUChars() for
  1.1319 + *                      conversion from the pivot buffer to the target buffer.
  1.1320 + * @param pivotTarget   I/O parameter, same as target in ucnv_toUChars() for
  1.1321 + *                      conversion from the source buffer to the pivot buffer.
  1.1322 + *                      It must be pivotStart<=*pivotSource<=*pivotTarget<=pivotLimit
  1.1323 + *                      and pivotStart<pivotLimit (unless pivotStart==NULL).
  1.1324 + * @param pivotLimit    Pointer to the first unit after the pivot buffer.
  1.1325 + * @param reset         If TRUE, then ucnv_resetToUnicode(sourceCnv) and
  1.1326 + *                      ucnv_resetFromUnicode(targetCnv) are called, and the
  1.1327 + *                      pivot pointers are reset (*pivotTarget=*pivotSource=pivotStart).
  1.1328 + * @param flush         If true, indicates the end of the input.
  1.1329 + *                      Passed directly to ucnv_toUnicode(), and carried over to
  1.1330 + *                      ucnv_fromUnicode() when the source is empty as well.
  1.1331 + * @param pErrorCode    ICU error code in/out parameter.
  1.1332 + *                      Must fulfill U_SUCCESS before the function call.
  1.1333 + *                      U_BUFFER_OVERFLOW_ERROR always refers to the target buffer
  1.1334 + *                      because overflows into the pivot buffer are handled internally.
  1.1335 + *                      Other conversion errors are from the source-to-pivot
  1.1336 + *                      conversion if *pivotSource==pivotStart, otherwise from
  1.1337 + *                      the pivot-to-target conversion.
  1.1338 + *
  1.1339 + * @see ucnv_convert
  1.1340 + * @see ucnv_fromAlgorithmic
  1.1341 + * @see ucnv_toAlgorithmic
  1.1342 + * @see ucnv_fromUnicode
  1.1343 + * @see ucnv_toUnicode
  1.1344 + * @see ucnv_fromUChars
  1.1345 + * @see ucnv_toUChars
  1.1346 + * @stable ICU 2.6
  1.1347 + */
  1.1348 +U_STABLE void U_EXPORT2
  1.1349 +ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
  1.1350 +               char **target, const char *targetLimit,
  1.1351 +               const char **source, const char *sourceLimit,
  1.1352 +               UChar *pivotStart, UChar **pivotSource,
  1.1353 +               UChar **pivotTarget, const UChar *pivotLimit,
  1.1354 +               UBool reset, UBool flush,
  1.1355 +               UErrorCode *pErrorCode);
  1.1356 +
  1.1357 +/**
  1.1358 + * Convert from one external charset to another.
  1.1359 + * Internally, two converters are opened according to the name arguments,
  1.1360 + * then the text is converted to and from the 16-bit Unicode "pivot"
  1.1361 + * using ucnv_convertEx(), then the converters are closed again.
  1.1362 + *
  1.1363 + * This is a convenience function, not an efficient way to convert a lot of text:
  1.1364 + * ucnv_convert()
  1.1365 + * - takes charset names, not converter objects, so that
  1.1366 + *   - two converters are opened for each call
  1.1367 + *   - only single-string conversion is possible, not streaming operation
  1.1368 + * - does not provide enough information to find out,
  1.1369 + *   in case of failure, whether the toUnicode or
  1.1370 + *   the fromUnicode conversion failed
  1.1371 + * - allows NUL-terminated input
  1.1372 + *   (only a single NUL byte, will not work for charsets with multi-byte NULs)
  1.1373 + *   (if sourceLength==-1, see parameters)
  1.1374 + * - terminate with a NUL on output
  1.1375 + *   (only a single NUL byte, not useful for charsets with multi-byte NULs),
  1.1376 + *   or set U_STRING_NOT_TERMINATED_WARNING if the output exactly fills
  1.1377 + *   the target buffer
  1.1378 + * - a pivot buffer is provided internally
  1.1379 + *
  1.1380 + * The function returns when one of the following is true:
  1.1381 + * - the entire source text has been converted successfully to the target buffer
  1.1382 + *   and either the target buffer is terminated with a single NUL byte
  1.1383 + *   or the error code is set to U_STRING_NOT_TERMINATED_WARNING
  1.1384 + * - a target buffer overflow occurred (U_BUFFER_OVERFLOW_ERROR)
  1.1385 + *   and the full output string length is returned ("preflighting")
  1.1386 + * - a conversion error occurred
  1.1387 + *   (other U_FAILURE(), see description of pErrorCode)
  1.1388 + *
  1.1389 + * @param toConverterName   The name of the converter that is used to convert
  1.1390 + *                          from the UTF-16 pivot buffer to the target.
  1.1391 + * @param fromConverterName The name of the converter that is used to convert
  1.1392 + *                          from the source to the UTF-16 pivot buffer.
  1.1393 + * @param target            Pointer to the output buffer.
  1.1394 + * @param targetCapacity    Capacity of the target, in bytes.
  1.1395 + * @param source            Pointer to the input buffer.
  1.1396 + * @param sourceLength      Length of the input text, in bytes, or -1 for NUL-terminated input.
  1.1397 + * @param pErrorCode        ICU error code in/out parameter.
  1.1398 + *                          Must fulfill U_SUCCESS before the function call.
  1.1399 + * @return Length of the complete output text in bytes, even if it exceeds the targetCapacity
  1.1400 + *         and a U_BUFFER_OVERFLOW_ERROR is set.
  1.1401 + *
  1.1402 + * @see ucnv_convertEx
  1.1403 + * @see ucnv_fromAlgorithmic
  1.1404 + * @see ucnv_toAlgorithmic
  1.1405 + * @see ucnv_fromUnicode
  1.1406 + * @see ucnv_toUnicode
  1.1407 + * @see ucnv_fromUChars
  1.1408 + * @see ucnv_toUChars
  1.1409 + * @see ucnv_getNextUChar
  1.1410 + * @stable ICU 2.0
  1.1411 + */
  1.1412 +U_STABLE int32_t U_EXPORT2
  1.1413 +ucnv_convert(const char *toConverterName,
  1.1414 +             const char *fromConverterName,
  1.1415 +             char *target,
  1.1416 +             int32_t targetCapacity,
  1.1417 +             const char *source,
  1.1418 +             int32_t sourceLength,
  1.1419 +             UErrorCode *pErrorCode);
  1.1420 +
  1.1421 +/**
  1.1422 + * Convert from one external charset to another.
  1.1423 + * Internally, the text is converted to and from the 16-bit Unicode "pivot"
  1.1424 + * using ucnv_convertEx(). ucnv_toAlgorithmic() works exactly like ucnv_convert()
  1.1425 + * except that the two converters need not be looked up and opened completely.
  1.1426 + *
  1.1427 + * The source-to-pivot conversion uses the cnv converter parameter.
  1.1428 + * The pivot-to-target conversion uses a purely algorithmic converter
  1.1429 + * according to the specified type, e.g., UCNV_UTF8 for a UTF-8 converter.
  1.1430 + *
  1.1431 + * Internally, the algorithmic converter is opened and closed for each
  1.1432 + * function call, which is more efficient than using the public ucnv_open()
  1.1433 + * but somewhat less efficient than only resetting an existing converter
  1.1434 + * and using ucnv_convertEx().
  1.1435 + *
  1.1436 + * This function is more convenient than ucnv_convertEx() for single-string
  1.1437 + * conversions, especially when "preflighting" is desired (returning the length
  1.1438 + * of the complete output even if it does not fit into the target buffer;
  1.1439 + * see the User Guide Strings chapter). See ucnv_convert() for details.
  1.1440 + *
  1.1441 + * @param algorithmicType   UConverterType constant identifying the desired target
  1.1442 + *                          charset as a purely algorithmic converter.
  1.1443 + *                          Those are converters for Unicode charsets like
  1.1444 + *                          UTF-8, BOCU-1, SCSU, UTF-7, IMAP-mailbox-name, etc.,
  1.1445 + *                          as well as US-ASCII and ISO-8859-1.
  1.1446 + * @param cnv               The converter that is used to convert
  1.1447 + *                          from the source to the UTF-16 pivot buffer.
  1.1448 + * @param target            Pointer to the output buffer.
  1.1449 + * @param targetCapacity    Capacity of the target, in bytes.
  1.1450 + * @param source            Pointer to the input buffer.
  1.1451 + * @param sourceLength      Length of the input text, in bytes
  1.1452 + * @param pErrorCode        ICU error code in/out parameter.
  1.1453 + *                          Must fulfill U_SUCCESS before the function call.
  1.1454 + * @return Length of the complete output text in bytes, even if it exceeds the targetCapacity
  1.1455 + *         and a U_BUFFER_OVERFLOW_ERROR is set.
  1.1456 + *
  1.1457 + * @see ucnv_fromAlgorithmic
  1.1458 + * @see ucnv_convert
  1.1459 + * @see ucnv_convertEx
  1.1460 + * @see ucnv_fromUnicode
  1.1461 + * @see ucnv_toUnicode
  1.1462 + * @see ucnv_fromUChars
  1.1463 + * @see ucnv_toUChars
  1.1464 + * @stable ICU 2.6
  1.1465 + */
  1.1466 +U_STABLE int32_t U_EXPORT2
  1.1467 +ucnv_toAlgorithmic(UConverterType algorithmicType,
  1.1468 +                   UConverter *cnv,
  1.1469 +                   char *target, int32_t targetCapacity,
  1.1470 +                   const char *source, int32_t sourceLength,
  1.1471 +                   UErrorCode *pErrorCode);
  1.1472 +
  1.1473 +/**
  1.1474 + * Convert from one external charset to another.
  1.1475 + * Internally, the text is converted to and from the 16-bit Unicode "pivot"
  1.1476 + * using ucnv_convertEx(). ucnv_fromAlgorithmic() works exactly like ucnv_convert()
  1.1477 + * except that the two converters need not be looked up and opened completely.
  1.1478 + *
  1.1479 + * The source-to-pivot conversion uses a purely algorithmic converter
  1.1480 + * according to the specified type, e.g., UCNV_UTF8 for a UTF-8 converter.
  1.1481 + * The pivot-to-target conversion uses the cnv converter parameter.
  1.1482 + *
  1.1483 + * Internally, the algorithmic converter is opened and closed for each
  1.1484 + * function call, which is more efficient than using the public ucnv_open()
  1.1485 + * but somewhat less efficient than only resetting an existing converter
  1.1486 + * and using ucnv_convertEx().
  1.1487 + *
  1.1488 + * This function is more convenient than ucnv_convertEx() for single-string
  1.1489 + * conversions, especially when "preflighting" is desired (returning the length
  1.1490 + * of the complete output even if it does not fit into the target buffer;
  1.1491 + * see the User Guide Strings chapter). See ucnv_convert() for details.
  1.1492 + *
  1.1493 + * @param cnv               The converter that is used to convert
  1.1494 + *                          from the UTF-16 pivot buffer to the target.
  1.1495 + * @param algorithmicType   UConverterType constant identifying the desired source
  1.1496 + *                          charset as a purely algorithmic converter.
  1.1497 + *                          Those are converters for Unicode charsets like
  1.1498 + *                          UTF-8, BOCU-1, SCSU, UTF-7, IMAP-mailbox-name, etc.,
  1.1499 + *                          as well as US-ASCII and ISO-8859-1.
  1.1500 + * @param target            Pointer to the output buffer.
  1.1501 + * @param targetCapacity    Capacity of the target, in bytes.
  1.1502 + * @param source            Pointer to the input buffer.
  1.1503 + * @param sourceLength      Length of the input text, in bytes
  1.1504 + * @param pErrorCode        ICU error code in/out parameter.
  1.1505 + *                          Must fulfill U_SUCCESS before the function call.
  1.1506 + * @return Length of the complete output text in bytes, even if it exceeds the targetCapacity
  1.1507 + *         and a U_BUFFER_OVERFLOW_ERROR is set.
  1.1508 + *
  1.1509 + * @see ucnv_fromAlgorithmic
  1.1510 + * @see ucnv_convert
  1.1511 + * @see ucnv_convertEx
  1.1512 + * @see ucnv_fromUnicode
  1.1513 + * @see ucnv_toUnicode
  1.1514 + * @see ucnv_fromUChars
  1.1515 + * @see ucnv_toUChars
  1.1516 + * @stable ICU 2.6
  1.1517 + */
  1.1518 +U_STABLE int32_t U_EXPORT2
  1.1519 +ucnv_fromAlgorithmic(UConverter *cnv,
  1.1520 +                     UConverterType algorithmicType,
  1.1521 +                     char *target, int32_t targetCapacity,
  1.1522 +                     const char *source, int32_t sourceLength,
  1.1523 +                     UErrorCode *pErrorCode);
  1.1524 +
  1.1525 +/**
  1.1526 + * Frees up memory occupied by unused, cached converter shared data.
  1.1527 + *
  1.1528 + * @return the number of cached converters successfully deleted
  1.1529 + * @see ucnv_close
  1.1530 + * @stable ICU 2.0
  1.1531 + */
  1.1532 +U_STABLE int32_t U_EXPORT2
  1.1533 +ucnv_flushCache(void);
  1.1534 +
  1.1535 +/**
  1.1536 + * Returns the number of available converters, as per the alias file.
  1.1537 + *
  1.1538 + * @return the number of available converters
  1.1539 + * @see ucnv_getAvailableName
  1.1540 + * @stable ICU 2.0
  1.1541 + */
  1.1542 +U_STABLE int32_t U_EXPORT2
  1.1543 +ucnv_countAvailable(void);
  1.1544 +
  1.1545 +/**
  1.1546 + * Gets the canonical converter name of the specified converter from a list of
  1.1547 + * all available converters contaied in the alias file. All converters
  1.1548 + * in this list can be opened.
  1.1549 + *
  1.1550 + * @param n the index to a converter available on the system (in the range <TT>[0..ucnv_countAvaiable()]</TT>)
  1.1551 + * @return a pointer a string (library owned), or <TT>NULL</TT> if the index is out of bounds.
  1.1552 + * @see ucnv_countAvailable
  1.1553 + * @stable ICU 2.0
  1.1554 + */
  1.1555 +U_STABLE const char* U_EXPORT2
  1.1556 +ucnv_getAvailableName(int32_t n);
  1.1557 +
  1.1558 +/**
  1.1559 + * Returns a UEnumeration to enumerate all of the canonical converter
  1.1560 + * names, as per the alias file, regardless of the ability to open each
  1.1561 + * converter.
  1.1562 + *
  1.1563 + * @return A UEnumeration object for getting all the recognized canonical
  1.1564 + *   converter names.
  1.1565 + * @see ucnv_getAvailableName
  1.1566 + * @see uenum_close
  1.1567 + * @see uenum_next
  1.1568 + * @stable ICU 2.4
  1.1569 + */
  1.1570 +U_STABLE UEnumeration * U_EXPORT2
  1.1571 +ucnv_openAllNames(UErrorCode *pErrorCode);
  1.1572 +
  1.1573 +/**
  1.1574 + * Gives the number of aliases for a given converter or alias name.
  1.1575 + * If the alias is ambiguous, then the preferred converter is used
  1.1576 + * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
  1.1577 + * This method only enumerates the listed entries in the alias file.
  1.1578 + * @param alias alias name
  1.1579 + * @param pErrorCode error status
  1.1580 + * @return number of names on alias list for given alias
  1.1581 + * @stable ICU 2.0
  1.1582 + */
  1.1583 +U_STABLE uint16_t U_EXPORT2 
  1.1584 +ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
  1.1585 +
  1.1586 +/**
  1.1587 + * Gives the name of the alias at given index of alias list.
  1.1588 + * This method only enumerates the listed entries in the alias file.
  1.1589 + * If the alias is ambiguous, then the preferred converter is used
  1.1590 + * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
  1.1591 + * @param alias alias name
  1.1592 + * @param n index in alias list
  1.1593 + * @param pErrorCode result of operation
  1.1594 + * @return returns the name of the alias at given index
  1.1595 + * @see ucnv_countAliases
  1.1596 + * @stable ICU 2.0
  1.1597 + */
  1.1598 +U_STABLE const char * U_EXPORT2 
  1.1599 +ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
  1.1600 +
  1.1601 +/**
  1.1602 + * Fill-up the list of alias names for the given alias.
  1.1603 + * This method only enumerates the listed entries in the alias file.
  1.1604 + * If the alias is ambiguous, then the preferred converter is used
  1.1605 + * and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
  1.1606 + * @param alias alias name
  1.1607 + * @param aliases fill-in list, aliases is a pointer to an array of
  1.1608 + *        <code>ucnv_countAliases()</code> string-pointers
  1.1609 + *        (<code>const char *</code>) that will be filled in.
  1.1610 + *        The strings themselves are owned by the library.
  1.1611 + * @param pErrorCode result of operation
  1.1612 + * @stable ICU 2.0
  1.1613 + */
  1.1614 +U_STABLE void U_EXPORT2 
  1.1615 +ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);
  1.1616 +
  1.1617 +/**
  1.1618 + * Return a new UEnumeration object for enumerating all the
  1.1619 + * alias names for a given converter that are recognized by a standard.
  1.1620 + * This method only enumerates the listed entries in the alias file.
  1.1621 + * The convrtrs.txt file can be modified to change the results of
  1.1622 + * this function.
  1.1623 + * The first result in this list is the same result given by
  1.1624 + * <code>ucnv_getStandardName</code>, which is the default alias for
  1.1625 + * the specified standard name. The returned object must be closed with
  1.1626 + * <code>uenum_close</code> when you are done with the object.
  1.1627 + *
  1.1628 + * @param convName original converter name
  1.1629 + * @param standard name of the standard governing the names; MIME and IANA
  1.1630 + *      are such standards
  1.1631 + * @param pErrorCode The error code
  1.1632 + * @return A UEnumeration object for getting all aliases that are recognized
  1.1633 + *      by a standard. If any of the parameters are invalid, NULL
  1.1634 + *      is returned.
  1.1635 + * @see ucnv_getStandardName
  1.1636 + * @see uenum_close
  1.1637 + * @see uenum_next
  1.1638 + * @stable ICU 2.2
  1.1639 + */
  1.1640 +U_STABLE UEnumeration * U_EXPORT2
  1.1641 +ucnv_openStandardNames(const char *convName,
  1.1642 +                       const char *standard,
  1.1643 +                       UErrorCode *pErrorCode);
  1.1644 +
  1.1645 +/**
  1.1646 + * Gives the number of standards associated to converter names.
  1.1647 + * @return number of standards
  1.1648 + * @stable ICU 2.0
  1.1649 + */
  1.1650 +U_STABLE uint16_t U_EXPORT2
  1.1651 +ucnv_countStandards(void);
  1.1652 +
  1.1653 +/**
  1.1654 + * Gives the name of the standard at given index of standard list.
  1.1655 + * @param n index in standard list
  1.1656 + * @param pErrorCode result of operation
  1.1657 + * @return returns the name of the standard at given index. Owned by the library.
  1.1658 + * @stable ICU 2.0
  1.1659 + */
  1.1660 +U_STABLE const char * U_EXPORT2
  1.1661 +ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
  1.1662 +
  1.1663 +/**
  1.1664 + * Returns a standard name for a given converter name.
  1.1665 + * <p>
  1.1666 + * Example alias table:<br>
  1.1667 + * conv alias1 { STANDARD1 } alias2 { STANDARD1* }
  1.1668 + * <p>
  1.1669 + * Result of ucnv_getStandardName("conv", "STANDARD1") from example
  1.1670 + * alias table:<br>
  1.1671 + * <b>"alias2"</b>
  1.1672 + *
  1.1673 + * @param name original converter name
  1.1674 + * @param standard name of the standard governing the names; MIME and IANA
  1.1675 + *        are such standards
  1.1676 + * @param pErrorCode result of operation
  1.1677 + * @return returns the standard converter name;
  1.1678 + *         if a standard converter name cannot be determined,
  1.1679 + *         then <code>NULL</code> is returned. Owned by the library.
  1.1680 + * @stable ICU 2.0
  1.1681 + */
  1.1682 +U_STABLE const char * U_EXPORT2
  1.1683 +ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
  1.1684 +
  1.1685 +/**
  1.1686 + * This function will return the internal canonical converter name of the
  1.1687 + * tagged alias. This is the opposite of ucnv_openStandardNames, which
  1.1688 + * returns the tagged alias given the canonical name.
  1.1689 + * <p>
  1.1690 + * Example alias table:<br>
  1.1691 + * conv alias1 { STANDARD1 } alias2 { STANDARD1* }
  1.1692 + * <p>
  1.1693 + * Result of ucnv_getStandardName("alias1", "STANDARD1") from example
  1.1694 + * alias table:<br>
  1.1695 + * <b>"conv"</b>
  1.1696 + *
  1.1697 + * @return returns the canonical converter name;
  1.1698 + *         if a standard or alias name cannot be determined,
  1.1699 + *         then <code>NULL</code> is returned. The returned string is
  1.1700 + *         owned by the library.
  1.1701 + * @see ucnv_getStandardName
  1.1702 + * @stable ICU 2.4
  1.1703 + */
  1.1704 +U_STABLE const char * U_EXPORT2
  1.1705 +ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);
  1.1706 +
  1.1707 +/**
  1.1708 + * returns the current default converter name.
  1.1709 + *
  1.1710 + * @return returns the current default converter name;
  1.1711 + *         if a default converter name cannot be determined,
  1.1712 + *         then <code>NULL</code> is returned.
  1.1713 + *         Storage owned by the library
  1.1714 + * @see ucnv_setDefaultName
  1.1715 + * @stable ICU 2.0
  1.1716 + */
  1.1717 +U_STABLE const char * U_EXPORT2
  1.1718 +ucnv_getDefaultName(void);
  1.1719 +
  1.1720 +/**
  1.1721 + * sets the current default converter name. Caller must own the storage for 'name'
  1.1722 + * and preserve it indefinitely. 
  1.1723 + * @param name the converter name to be the default (must exist).
  1.1724 + * @see ucnv_getDefaultName
  1.1725 + * @system SYSTEM API
  1.1726 + * @stable ICU 2.0
  1.1727 + */
  1.1728 +U_STABLE void U_EXPORT2
  1.1729 +ucnv_setDefaultName(const char *name);
  1.1730 +
  1.1731 +/**
  1.1732 + * Fixes the backslash character mismapping.  For example, in SJIS, the backslash 
  1.1733 + * character in the ASCII portion is also used to represent the yen currency sign.  
  1.1734 + * When mapping from Unicode character 0x005C, it's unclear whether to map the 
  1.1735 + * character back to yen or backslash in SJIS.  This function will take the input
  1.1736 + * buffer and replace all the yen sign characters with backslash.  This is necessary
  1.1737 + * when the user tries to open a file with the input buffer on Windows.
  1.1738 + * This function will test the converter to see whether such mapping is
  1.1739 + * required.  You can sometimes avoid using this function by using the correct version
  1.1740 + * of Shift-JIS.
  1.1741 + *
  1.1742 + * @param cnv The converter representing the target codepage.
  1.1743 + * @param source the input buffer to be fixed
  1.1744 + * @param sourceLen the length of the input buffer
  1.1745 + * @see ucnv_isAmbiguous
  1.1746 + * @stable ICU 2.0
  1.1747 + */
  1.1748 +U_STABLE void U_EXPORT2
  1.1749 +ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);
  1.1750 +
  1.1751 +/**
  1.1752 + * Determines if the converter contains ambiguous mappings of the same
  1.1753 + * character or not.
  1.1754 + * @param cnv the converter to be tested
  1.1755 + * @return TRUE if the converter contains ambiguous mapping of the same 
  1.1756 + * character, FALSE otherwise.
  1.1757 + * @stable ICU 2.0
  1.1758 + */
  1.1759 +U_STABLE UBool U_EXPORT2
  1.1760 +ucnv_isAmbiguous(const UConverter *cnv);
  1.1761 +
  1.1762 +/**
  1.1763 + * Sets the converter to use fallback mapping or not.
  1.1764 + * @param cnv The converter to set the fallback mapping usage on.
  1.1765 + * @param usesFallback TRUE if the user wants the converter to take advantage of the fallback 
  1.1766 + * mapping, FALSE otherwise.
  1.1767 + * @stable ICU 2.0
  1.1768 + */
  1.1769 +U_STABLE void U_EXPORT2 
  1.1770 +ucnv_setFallback(UConverter *cnv, UBool usesFallback);
  1.1771 +
  1.1772 +/**
  1.1773 + * Determines if the converter uses fallback mappings or not.
  1.1774 + * @param cnv The converter to be tested
  1.1775 + * @return TRUE if the converter uses fallback, FALSE otherwise.
  1.1776 + * @stable ICU 2.0
  1.1777 + */
  1.1778 +U_STABLE UBool U_EXPORT2 
  1.1779 +ucnv_usesFallback(const UConverter *cnv);
  1.1780 +
  1.1781 +/**
  1.1782 + * Detects Unicode signature byte sequences at the start of the byte stream
  1.1783 + * and returns the charset name of the indicated Unicode charset.
  1.1784 + * NULL is returned when no Unicode signature is recognized.
  1.1785 + * The number of bytes in the signature is output as well.
  1.1786 + *
  1.1787 + * The caller can ucnv_open() a converter using the charset name.
  1.1788 + * The first code unit (UChar) from the start of the stream will be U+FEFF
  1.1789 + * (the Unicode BOM/signature character) and can usually be ignored.
  1.1790 + *
  1.1791 + * For most Unicode charsets it is also possible to ignore the indicated
  1.1792 + * number of initial stream bytes and start converting after them.
  1.1793 + * However, there are stateful Unicode charsets (UTF-7 and BOCU-1) for which
  1.1794 + * this will not work. Therefore, it is best to ignore the first output UChar
  1.1795 + * instead of the input signature bytes.
  1.1796 + * <p>
  1.1797 + * Usage:
  1.1798 + * @code     
  1.1799 + *      UErrorCode err = U_ZERO_ERROR;
  1.1800 + *      char input[] = { '\xEF','\xBB', '\xBF','\x41','\x42','\x43' };
  1.1801 + *      int32_t signatureLength = 0;
  1.1802 + *      char *encoding = ucnv_detectUnicodeSignatures(input,sizeof(input),&signatureLength,&err);
  1.1803 + *      UConverter *conv = NULL;
  1.1804 + *      UChar output[100];
  1.1805 + *      UChar *target = output, *out;
  1.1806 + *      char *source = input;
  1.1807 + *      if(encoding!=NULL && U_SUCCESS(err)){
  1.1808 + *          // should signature be discarded ?
  1.1809 + *          conv = ucnv_open(encoding, &err);
  1.1810 + *          // do the conversion
  1.1811 + *          ucnv_toUnicode(conv,
  1.1812 + *                         target, output + sizeof(output)/U_SIZEOF_UCHAR,
  1.1813 + *                         source, input + sizeof(input),
  1.1814 + *                         NULL, TRUE, &err);
  1.1815 + *          out = output;
  1.1816 + *          if (discardSignature){
  1.1817 + *              ++out; // ignore initial U+FEFF
  1.1818 + *          }
  1.1819 + *          while(out != target) {
  1.1820 + *              printf("%04x ", *out++);
  1.1821 + *          }
  1.1822 + *          puts("");
  1.1823 + *      }
  1.1824 + *     
  1.1825 + * @endcode
  1.1826 + *
  1.1827 + * @param source            The source string in which the signature should be detected.
  1.1828 + * @param sourceLength      Length of the input string, or -1 if terminated with a NUL byte.
  1.1829 + * @param signatureLength   A pointer to int32_t to receive the number of bytes that make up the signature 
  1.1830 + *                          of the detected UTF. 0 if not detected.
  1.1831 + *                          Can be a NULL pointer.
  1.1832 + * @param pErrorCode        ICU error code in/out parameter.
  1.1833 + *                          Must fulfill U_SUCCESS before the function call.
  1.1834 + * @return The name of the encoding detected. NULL if encoding is not detected. 
  1.1835 + * @stable ICU 2.4
  1.1836 + */
  1.1837 +U_STABLE const char* U_EXPORT2
  1.1838 +ucnv_detectUnicodeSignature(const char* source,
  1.1839 +                            int32_t sourceLength,
  1.1840 +                            int32_t *signatureLength,
  1.1841 +                            UErrorCode *pErrorCode);
  1.1842 +
  1.1843 +/**
  1.1844 + * Returns the number of UChars held in the converter's internal state 
  1.1845 + * because more input is needed for completing the conversion. This function is 
  1.1846 + * useful for mapping semantics of ICU's converter interface to those of iconv,
  1.1847 + * and this information is not needed for normal conversion.
  1.1848 + * @param cnv       The converter in which the input is held
  1.1849 + * @param status    ICU error code in/out parameter.
  1.1850 + *                  Must fulfill U_SUCCESS before the function call.
  1.1851 + * @return The number of UChars in the state. -1 if an error is encountered.
  1.1852 + * @draft ICU 3.4
  1.1853 + */
  1.1854 +U_DRAFT int32_t U_EXPORT2
  1.1855 +ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
  1.1856 +
  1.1857 +/**
  1.1858 + * Returns the number of chars held in the converter's internal state
  1.1859 + * because more input is needed for completing the conversion. This function is 
  1.1860 + * useful for mapping semantics of ICU's converter interface to those of iconv,
  1.1861 + * and this information is not needed for normal conversion.
  1.1862 + * @param cnv       The converter in which the input is held as internal state
  1.1863 + * @param status    ICU error code in/out parameter.
  1.1864 + *                  Must fulfill U_SUCCESS before the function call.
  1.1865 + * @return The number of chars in the state. -1 if an error is encountered.
  1.1866 + * @draft ICU 3.4
  1.1867 + */
  1.1868 +U_DRAFT int32_t U_EXPORT2
  1.1869 +ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
  1.1870 +
  1.1871 +#endif
  1.1872 +
  1.1873 +#endif
  1.1874 +/*_UCNV*/