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