1999-12-28 23:39:02 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
2011-02-23 22:21:58 +00:00
|
|
|
* Copyright (C) 1999-2011, International Business Machines
|
1999-12-28 23:39:02 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
|
|
|
* ucnv.h:
|
|
|
|
* External APIs for the ICU's codeset conversion library
|
|
|
|
* Bertrand A. Damiba
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 04/04/99 helena Fixed internal header inclusion.
|
2000-05-12 19:59:03 +00:00
|
|
|
* 05/11/00 helena Added setFallback and usesFallback APIs.
|
2000-06-27 20:47:56 +00:00
|
|
|
* 06/29/2000 helena Major rewrite of the callback APIs.
|
2000-12-08 21:36:47 +00:00
|
|
|
* 12/07/2000 srl Update of documentation
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2000-12-08 18:43:57 +00:00
|
|
|
* \file
|
2000-12-15 03:58:31 +00:00
|
|
|
* \brief C API: Character conversion
|
2000-12-08 18:43:57 +00:00
|
|
|
*
|
2002-08-27 23:01:04 +00:00
|
|
|
* <h2>Character Conversion C API</h2>
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
2002-08-27 23:01:04 +00:00
|
|
|
* <p>This API is used to convert codepage or character encoded data to and
|
2004-05-27 18:06:17 +00:00
|
|
|
* from UTF-16. You can open a converter with {@link ucnv_open() }. With that
|
2002-08-27 23:01:04 +00:00
|
|
|
* converter, you can get its properties, set options, convert your data and
|
|
|
|
* close the converter.</p>
|
|
|
|
*
|
|
|
|
* <p>Since many software programs recogize different converter names for
|
|
|
|
* different types of converters, there are other functions in this API to
|
2004-05-27 18:06:17 +00:00
|
|
|
* iterate over the converter aliases. The functions {@link ucnv_getAvailableName() },
|
|
|
|
* {@link ucnv_getAlias() } and {@link ucnv_getStandardName() } are some of the
|
2002-08-27 23:01:04 +00:00
|
|
|
* more frequently used alias functions to get this information.</p>
|
|
|
|
*
|
2003-04-16 22:39:22 +00:00
|
|
|
* <p>When a converter encounters an illegal, irregular, invalid or unmappable character
|
|
|
|
* its default behavior is to use a substitution character to replace the
|
2005-06-23 17:05:07 +00:00
|
|
|
* bad byte sequence. This behavior can be changed by using {@link ucnv_setFromUCallBack() }
|
|
|
|
* or {@link ucnv_setToUCallBack() } on the converter. The header ucnv_err.h defines
|
2003-04-16 22:39:22 +00:00
|
|
|
* many other callback actions that can be used instead of a character substitution.</p>
|
|
|
|
*
|
2002-08-27 23:01:04 +00:00
|
|
|
* <p>More information about this API can be found in our
|
2007-06-11 19:14:47 +00:00
|
|
|
* <a href="http://icu-project.org/userguide/conversion.html">User's
|
2002-08-27 23:01:04 +00:00
|
|
|
* Guide</a>.</p>
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UCNV_H
|
|
|
|
#define UCNV_H
|
|
|
|
|
|
|
|
#include "unicode/ucnv_err.h"
|
2002-07-13 16:32:16 +00:00
|
|
|
#include "unicode/uenum.h"
|
2009-11-14 00:36:06 +00:00
|
|
|
#include "unicode/localpointer.h"
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2003-04-05 01:33:02 +00:00
|
|
|
#ifndef __USET_H__
|
|
|
|
|
2003-06-02 16:33:21 +00:00
|
|
|
/**
|
|
|
|
* USet is the C API type for Unicode sets.
|
|
|
|
* It is forward-declared here to avoid including the header file if related
|
|
|
|
* conversion APIs are not used.
|
|
|
|
* See unicode/uset.h
|
|
|
|
*
|
|
|
|
* @see ucnv_getUnicodeSet
|
2004-11-02 07:28:07 +00:00
|
|
|
* @stable ICU 2.6
|
2003-06-02 16:33:21 +00:00
|
|
|
*/
|
2003-04-05 01:33:02 +00:00
|
|
|
struct USet;
|
2004-11-02 07:28:07 +00:00
|
|
|
/** @stable ICU 2.6 */
|
2003-04-05 01:33:02 +00:00
|
|
|
typedef struct USet USet;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2004-08-26 22:51:40 +00:00
|
|
|
#if !UCONFIG_NO_CONVERSION
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
U_CDECL_BEGIN
|
|
|
|
|
2002-12-12 00:27:50 +00:00
|
|
|
/** Maximum length of a converter name including the terminating NULL @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
#define UCNV_MAX_CONVERTER_NAME_LENGTH 60
|
2002-12-12 00:27:50 +00:00
|
|
|
/** Maximum length of a converter name including path and terminating NULL @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
#define UCNV_MAX_FULL_FILE_NAME_LENGTH (600+UCNV_MAX_CONVERTER_NAME_LENGTH)
|
|
|
|
|
2002-12-12 00:27:50 +00:00
|
|
|
/** Shift in for EBDCDIC_STATEFUL and iso2022 states @stable ICU 2.0 */
|
2002-07-26 16:05:08 +00:00
|
|
|
#define UCNV_SI 0x0F
|
2002-12-12 00:27:50 +00:00
|
|
|
/** Shift out for EBDCDIC_STATEFUL and iso2022 states @stable ICU 2.0 */
|
2002-07-26 16:05:08 +00:00
|
|
|
#define UCNV_SO 0x0E
|
2000-06-27 20:47:56 +00:00
|
|
|
|
2000-12-08 21:36:47 +00:00
|
|
|
/**
|
|
|
|
* Enum for specifying basic types of converters
|
|
|
|
* @see ucnv_getType
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-12-08 21:36:47 +00:00
|
|
|
*/
|
2000-06-27 20:47:56 +00:00
|
|
|
typedef enum {
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_UNSUPPORTED_CONVERTER = -1,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_SBCS = 0,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_DBCS = 1,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_MBCS = 2,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_LATIN_1 = 3,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_UTF8 = 4,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_UTF16_BigEndian = 5,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_UTF16_LittleEndian = 6,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-11-16 17:20:03 +00:00
|
|
|
UCNV_UTF32_BigEndian = 7,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-11-16 17:20:03 +00:00
|
|
|
UCNV_UTF32_LittleEndian = 8,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-11-16 17:20:03 +00:00
|
|
|
UCNV_EBCDIC_STATEFUL = 9,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-11-16 17:20:03 +00:00
|
|
|
UCNV_ISO_2022 = 10,
|
2000-10-17 08:03:36 +00:00
|
|
|
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-11-16 17:20:03 +00:00
|
|
|
UCNV_LMBCS_1 = 11,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_LMBCS_2,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2001-03-21 20:44:20 +00:00
|
|
|
UCNV_LMBCS_3,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_LMBCS_4,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_LMBCS_5,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_LMBCS_6,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_LMBCS_8,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_LMBCS_11,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_LMBCS_16,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_LMBCS_17,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_LMBCS_18,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-06-27 20:47:56 +00:00
|
|
|
UCNV_LMBCS_19,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-12-19 01:57:00 +00:00
|
|
|
UCNV_LMBCS_LAST = UCNV_LMBCS_19,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-10-17 08:03:36 +00:00
|
|
|
UCNV_HZ,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-12-19 01:57:00 +00:00
|
|
|
UCNV_SCSU,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2001-07-14 02:29:44 +00:00
|
|
|
UCNV_ISCII,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2000-12-20 02:08:39 +00:00
|
|
|
UCNV_US_ASCII,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.0 */
|
2001-01-09 03:33:07 +00:00
|
|
|
UCNV_UTF7,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.2 */
|
2002-04-17 20:36:53 +00:00
|
|
|
UCNV_BOCU1,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.2 */
|
2002-06-11 04:43:45 +00:00
|
|
|
UCNV_UTF16,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.2 */
|
2002-06-11 04:43:45 +00:00
|
|
|
UCNV_UTF32,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.2 */
|
2002-07-02 22:27:19 +00:00
|
|
|
UCNV_CESU8,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @stable ICU 2.4 */
|
2002-11-07 21:02:24 +00:00
|
|
|
UCNV_IMAP_MAILBOX,
|
2011-05-13 20:51:26 +00:00
|
|
|
/** @draft ICU 4.8 */
|
2010-12-15 23:38:28 +00:00
|
|
|
UCNV_COMPOUND_TEXT,
|
2000-06-27 20:47:56 +00:00
|
|
|
|
|
|
|
/* Number of converter types for which we have conversion routines. */
|
2000-12-19 01:57:00 +00:00
|
|
|
UCNV_NUMBER_OF_SUPPORTED_CONVERTER_TYPES
|
2000-06-27 20:47:56 +00:00
|
|
|
} UConverterType;
|
|
|
|
|
2000-12-08 21:36:47 +00:00
|
|
|
/**
|
2001-03-17 01:36:48 +00:00
|
|
|
* Enum for specifying which platform a converter ID refers to.
|
|
|
|
* The use of platform/CCSID is not recommended. See ucnv_openCCSID().
|
|
|
|
*
|
2000-12-08 21:36:47 +00:00
|
|
|
* @see ucnv_getPlatform
|
|
|
|
* @see ucnv_openCCSID
|
2001-03-17 01:36:48 +00:00
|
|
|
* @see ucnv_getCCSID
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-12-08 21:36:47 +00:00
|
|
|
*/
|
2000-06-27 20:47:56 +00:00
|
|
|
typedef enum {
|
|
|
|
UCNV_UNKNOWN = -1,
|
|
|
|
UCNV_IBM = 0
|
|
|
|
} UConverterPlatform;
|
|
|
|
|
2000-12-08 21:36:47 +00:00
|
|
|
/**
|
|
|
|
* Function pointer for error callback in the codepage to unicode direction.
|
|
|
|
* Called when an error has occured in conversion to unicode, or on open/close of the callback (see reason).
|
|
|
|
* @param context Pointer to the callback's private data
|
|
|
|
* @param args Information about the conversion in progress
|
2003-06-10 22:45:47 +00:00
|
|
|
* @param codeUnits Points to 'length' bytes of the concerned codepage sequence
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param length Size (in bytes) of the concerned codepage sequence
|
|
|
|
* @param reason Defines the reason the callback was invoked
|
2005-06-23 17:05:07 +00:00
|
|
|
* @param pErrorCode ICU error code in/out parameter.
|
|
|
|
* For converter callback functions, set to a conversion error
|
|
|
|
* before the call, and the callback may reset it to U_ZERO_ERROR.
|
2000-12-08 21:36:47 +00:00
|
|
|
* @see ucnv_setToUCallBack
|
|
|
|
* @see UConverterToUnicodeArgs
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-12-08 21:36:47 +00:00
|
|
|
*/
|
2001-11-21 01:02:11 +00:00
|
|
|
typedef void (U_EXPORT2 *UConverterToUCallback) (
|
2001-06-26 22:51:14 +00:00
|
|
|
const void* context,
|
2000-06-27 20:47:56 +00:00
|
|
|
UConverterToUnicodeArgs *args,
|
2003-06-10 22:45:47 +00:00
|
|
|
const char *codeUnits,
|
2000-06-27 20:47:56 +00:00
|
|
|
int32_t length,
|
|
|
|
UConverterCallbackReason reason,
|
2005-06-23 17:05:07 +00:00
|
|
|
UErrorCode *pErrorCode);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-12-08 21:36:47 +00:00
|
|
|
/**
|
|
|
|
* Function pointer for error callback in the unicode to codepage direction.
|
|
|
|
* Called when an error has occured in conversion from unicode, or on open/close of the callback (see reason).
|
|
|
|
* @param context Pointer to the callback's private data
|
|
|
|
* @param args Information about the conversion in progress
|
|
|
|
* @param codeUnits Points to 'length' UChars of the concerned Unicode sequence
|
|
|
|
* @param length Size (in bytes) of the concerned codepage sequence
|
|
|
|
* @param codePoint Single UChar32 (UTF-32) containing the concerend Unicode codepoint.
|
|
|
|
* @param reason Defines the reason the callback was invoked
|
2005-06-23 17:05:07 +00:00
|
|
|
* @param pErrorCode ICU error code in/out parameter.
|
|
|
|
* For converter callback functions, set to a conversion error
|
|
|
|
* before the call, and the callback may reset it to U_ZERO_ERROR.
|
2000-12-08 21:36:47 +00:00
|
|
|
* @see ucnv_setFromUCallBack
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-12-08 21:36:47 +00:00
|
|
|
*/
|
2001-11-21 01:02:11 +00:00
|
|
|
typedef void (U_EXPORT2 *UConverterFromUCallback) (
|
2001-06-26 22:51:14 +00:00
|
|
|
const void* context,
|
2000-06-27 20:47:56 +00:00
|
|
|
UConverterFromUnicodeArgs *args,
|
|
|
|
const UChar* codeUnits,
|
|
|
|
int32_t length,
|
2000-12-08 21:36:47 +00:00
|
|
|
UChar32 codePoint,
|
2000-06-27 20:47:56 +00:00
|
|
|
UConverterCallbackReason reason,
|
2005-06-23 17:05:07 +00:00
|
|
|
UErrorCode *pErrorCode);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
U_CDECL_END
|
|
|
|
|
2000-05-22 20:15:09 +00:00
|
|
|
/**
|
|
|
|
* Character that separates converter names from options and options from each other.
|
|
|
|
* @see ucnv_open
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-22 20:15:09 +00:00
|
|
|
*/
|
|
|
|
#define UCNV_OPTION_SEP_CHAR ','
|
|
|
|
|
2000-12-08 21:36:47 +00:00
|
|
|
/**
|
|
|
|
* String version of UCNV_OPTION_SEP_CHAR.
|
|
|
|
* @see ucnv_open
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-12-08 21:36:47 +00:00
|
|
|
*/
|
2000-05-22 20:15:09 +00:00
|
|
|
#define UCNV_OPTION_SEP_STRING ","
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Character that separates a converter option from its value.
|
|
|
|
* @see ucnv_open
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-22 20:15:09 +00:00
|
|
|
*/
|
|
|
|
#define UCNV_VALUE_SEP_CHAR '='
|
|
|
|
|
2000-12-08 21:36:47 +00:00
|
|
|
/**
|
|
|
|
* String version of UCNV_VALUE_SEP_CHAR.
|
|
|
|
* @see ucnv_open
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-12-08 21:36:47 +00:00
|
|
|
*/
|
2000-05-22 20:15:09 +00:00
|
|
|
#define UCNV_VALUE_SEP_STRING "="
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converter option for specifying a locale.
|
2002-09-18 01:27:37 +00:00
|
|
|
* For example, ucnv_open("SCSU,locale=ja", &errorCode);
|
|
|
|
* See convrtrs.txt.
|
|
|
|
*
|
2000-05-22 20:15:09 +00:00
|
|
|
* @see ucnv_open
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-05-22 20:15:09 +00:00
|
|
|
*/
|
|
|
|
#define UCNV_LOCALE_OPTION_STRING ",locale="
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2002-09-18 01:27:37 +00:00
|
|
|
/**
|
|
|
|
* Converter option for specifying a version selector (0..9) for some converters.
|
2008-10-01 01:24:46 +00:00
|
|
|
* For example,
|
|
|
|
* \code
|
|
|
|
* ucnv_open("UTF-7,version=1", &errorCode);
|
|
|
|
* \endcode
|
2002-09-18 01:27:37 +00:00
|
|
|
* See convrtrs.txt.
|
|
|
|
*
|
|
|
|
* @see ucnv_open
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-09-18 01:27:37 +00:00
|
|
|
*/
|
|
|
|
#define UCNV_VERSION_OPTION_STRING ",version="
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converter option for EBCDIC SBCS or mixed-SBCS/DBCS (stateful) codepages.
|
|
|
|
* Swaps Unicode mappings for EBCDIC LF and NL codes, as used on
|
|
|
|
* S/390 (z/OS) Unix System Services (Open Edition).
|
|
|
|
* For example, ucnv_open("ibm-1047,swaplfnl", &errorCode);
|
|
|
|
* See convrtrs.txt.
|
|
|
|
*
|
|
|
|
* @see ucnv_open
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-09-18 01:27:37 +00:00
|
|
|
*/
|
|
|
|
#define UCNV_SWAP_LFNL_OPTION_STRING ",swaplfnl"
|
|
|
|
|
2000-11-17 05:02:31 +00:00
|
|
|
/**
|
2006-06-28 23:16:45 +00:00
|
|
|
* Do a fuzzy compare of two converter/alias names.
|
|
|
|
* The comparison is case-insensitive, ignores leading zeroes if they are not
|
|
|
|
* followed by further digits, and ignores all but letters and digits.
|
|
|
|
* Thus the strings "UTF-8", "utf_8", "u*T@f08" and "Utf 8" are exactly equivalent.
|
|
|
|
* See section 1.4, Charset Alias Matching in Unicode Technical Standard #22
|
|
|
|
* at http://www.unicode.org/reports/tr22/
|
|
|
|
*
|
2000-11-17 05:02:31 +00:00
|
|
|
* @param name1 a converter name or alias, zero-terminated
|
|
|
|
* @param name2 a converter name or alias, zero-terminated
|
|
|
|
* @return 0 if the names match, or a negative value if the name1
|
|
|
|
* lexically precedes name2, or a positive value if the name1
|
|
|
|
* lexically follows name2.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-11-17 05:02:31 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE int U_EXPORT2
|
2000-11-17 06:07:31 +00:00
|
|
|
ucnv_compareNames(const char *name1, const char *name2);
|
2000-11-17 05:02:31 +00:00
|
|
|
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2006-01-06 23:40:00 +00:00
|
|
|
* Creates a UConverter object with the name of a coded character set specified as a C string.
|
2000-07-19 22:18:43 +00:00
|
|
|
* The actual name will be resolved with the alias file
|
|
|
|
* using a case-insensitive string comparison that ignores
|
2006-06-28 23:16:45 +00:00
|
|
|
* leading zeroes and all non-alphanumeric characters.
|
|
|
|
* E.g., the names "UTF8", "utf-8", "u*T@f08" and "Utf 8" are all equivalent.
|
|
|
|
* (See also ucnv_compareNames().)
|
2000-05-22 20:15:09 +00:00
|
|
|
* If <code>NULL</code> is passed for the converter name, it will create one with the
|
1999-12-28 23:39:02 +00:00
|
|
|
* getDefaultName return value.
|
2000-05-22 20:15:09 +00:00
|
|
|
*
|
|
|
|
* <p>A converter name for ICU 1.5 and above may contain options
|
|
|
|
* like a locale specification to control the specific behavior of
|
|
|
|
* the newly instantiated converter.
|
|
|
|
* The meaning of the options depends on the particular converter.
|
|
|
|
* If an option is not defined for or recognized by a given converter, then it is ignored.</p>
|
|
|
|
*
|
|
|
|
* <p>Options are appended to the converter name string, with a
|
|
|
|
* <code>UCNV_OPTION_SEP_CHAR</code> between the name and the first option and
|
|
|
|
* also between adjacent options.</p>
|
|
|
|
*
|
2003-06-12 22:36:22 +00:00
|
|
|
* <p>If the alias is ambiguous, then the preferred converter is used
|
|
|
|
* and the status is set to U_AMBIGUOUS_ALIAS_WARNING.</p>
|
|
|
|
*
|
|
|
|
* <p>The conversion behavior and names can vary between platforms. ICU may
|
|
|
|
* convert some characters differently from other platforms. Details on this topic
|
2007-06-11 19:14:47 +00:00
|
|
|
* are in the <a href="http://icu-project.org/userguide/conversion.html">User's
|
2006-01-06 23:40:00 +00:00
|
|
|
* Guide</a>. Aliases starting with a "cp" prefix have no specific meaning
|
|
|
|
* other than its an alias starting with the letters "cp". Please do not
|
|
|
|
* associate any meaning to these aliases.</p>
|
2003-06-12 22:36:22 +00:00
|
|
|
*
|
2006-01-06 23:40:00 +00:00
|
|
|
* @param converterName Name of the coded character set table.
|
|
|
|
* This may have options appended to the string.
|
|
|
|
* IANA alias character set names, IBM CCSIDs starting with "ibm-",
|
|
|
|
* Windows codepage numbers starting with "windows-" are frequently
|
|
|
|
* used for this parameter. See ucnv_getAvailableName and
|
|
|
|
* ucnv_getAlias for a complete list that is available.
|
|
|
|
* If this parameter is NULL, the default converter will be used.
|
2001-11-26 18:20:38 +00:00
|
|
|
* @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return the created Unicode converter object, or <TT>NULL</TT> if an error occured
|
|
|
|
* @see ucnv_openU
|
|
|
|
* @see ucnv_openCCSID
|
2006-01-06 23:40:00 +00:00
|
|
|
* @see ucnv_getAvailableName
|
|
|
|
* @see ucnv_getAlias
|
|
|
|
* @see ucnv_getDefaultName
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_close
|
2008-05-21 21:34:54 +00:00
|
|
|
* @see ucnv_compareNames
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE UConverter* U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_open(const char *converterName, UErrorCode *err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Creates a Unicode converter with the names specified as unicode string.
|
|
|
|
* The name should be limited to the ASCII-7 alphanumerics range.
|
2000-07-19 22:18:43 +00:00
|
|
|
* The actual name will be resolved with the alias file
|
|
|
|
* using a case-insensitive string comparison that ignores
|
2006-06-28 23:16:45 +00:00
|
|
|
* leading zeroes and all non-alphanumeric characters.
|
|
|
|
* E.g., the names "UTF8", "utf-8", "u*T@f08" and "Utf 8" are all equivalent.
|
|
|
|
* (See also ucnv_compareNames().)
|
2000-12-08 21:36:47 +00:00
|
|
|
* If <TT>NULL</TT> is passed for the converter name, it will create
|
|
|
|
* one with the ucnv_getDefaultName() return value.
|
2002-08-08 22:46:05 +00:00
|
|
|
* If the alias is ambiguous, then the preferred converter is used
|
|
|
|
* and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
|
2006-01-06 23:40:00 +00:00
|
|
|
*
|
|
|
|
* <p>See ucnv_open for the complete details</p>
|
|
|
|
* @param name Name of the UConverter table in a zero terminated
|
2000-12-08 21:36:47 +00:00
|
|
|
* Unicode string
|
|
|
|
* @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR,
|
2001-11-26 18:20:38 +00:00
|
|
|
* U_FILE_ACCESS_ERROR</TT>
|
2000-12-08 21:36:47 +00:00
|
|
|
* @return the created Unicode converter object, or <TT>NULL</TT> if an
|
|
|
|
* error occured
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_open
|
|
|
|
* @see ucnv_openCCSID
|
|
|
|
* @see ucnv_close
|
2008-05-21 21:34:54 +00:00
|
|
|
* @see ucnv_compareNames
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE UConverter* U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_openU(const UChar *name,
|
|
|
|
UErrorCode *err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2001-03-17 01:36:48 +00:00
|
|
|
* Creates a UConverter object from a CCSID number and platform pair.
|
|
|
|
* Note that the usefulness of this function is limited to platforms with numeric
|
|
|
|
* encoding IDs. Only IBM and Microsoft platforms use numeric (16-bit) identifiers for
|
|
|
|
* encodings.
|
|
|
|
*
|
|
|
|
* In addition, IBM CCSIDs and Unicode conversion tables are not 1:1 related.
|
|
|
|
* For many IBM CCSIDs there are multiple (up to six) Unicode conversion tables, and
|
|
|
|
* for some Unicode conversion tables there are multiple CCSIDs.
|
|
|
|
* Some "alternate" Unicode conversion tables are provided by the
|
|
|
|
* IBM CDRA conversion table registry.
|
|
|
|
* The most prominent example of a systematic modification of conversion tables that is
|
|
|
|
* not provided in the form of conversion table files in the repository is
|
|
|
|
* that S/390 Unix System Services swaps the codes for Line Feed and New Line in all
|
|
|
|
* EBCDIC codepages, which requires such a swap in the Unicode conversion tables as well.
|
|
|
|
*
|
|
|
|
* Only IBM default conversion tables are accessible with ucnv_openCCSID().
|
|
|
|
* ucnv_getCCSID() will return the same CCSID for all conversion tables that are associated
|
|
|
|
* with that CCSID.
|
|
|
|
*
|
|
|
|
* Currently, the only "platform" supported in the ICU converter API is UCNV_IBM.
|
|
|
|
*
|
|
|
|
* In summary, the use of CCSIDs and the associated API functions is not recommended.
|
|
|
|
*
|
|
|
|
* In order to open a converter with the default IBM CDRA Unicode conversion table,
|
|
|
|
* you can use this function or use the prefix "ibm-":
|
|
|
|
* \code
|
|
|
|
* char name[20];
|
|
|
|
* sprintf(name, "ibm-%hu", ccsid);
|
|
|
|
* cnv=ucnv_open(name, &errorCode);
|
|
|
|
* \endcode
|
|
|
|
*
|
2002-09-18 01:27:37 +00:00
|
|
|
* In order to open a converter with the IBM S/390 Unix System Services variant
|
|
|
|
* of a Unicode/EBCDIC conversion table,
|
|
|
|
* you can use the prefix "ibm-" together with the option string UCNV_SWAP_LFNL_OPTION_STRING:
|
2001-03-17 01:36:48 +00:00
|
|
|
* \code
|
|
|
|
* char name[20];
|
2002-09-18 01:27:37 +00:00
|
|
|
* sprintf(name, "ibm-%hu" UCNV_SWAP_LFNL_OPTION_STRING, ccsid);
|
2001-03-17 01:36:48 +00:00
|
|
|
* cnv=ucnv_open(name, &errorCode);
|
|
|
|
* \endcode
|
|
|
|
*
|
|
|
|
* In order to open a converter from a Microsoft codepage number, use the prefix "cp":
|
|
|
|
* \code
|
|
|
|
* char name[20];
|
|
|
|
* sprintf(name, "cp%hu", codepageID);
|
|
|
|
* cnv=ucnv_open(name, &errorCode);
|
|
|
|
* \endcode
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
2002-08-08 22:46:05 +00:00
|
|
|
* If the alias is ambiguous, then the preferred converter is used
|
|
|
|
* and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
|
|
|
|
*
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param codepage codepage number to create
|
|
|
|
* @param platform the platform in which the codepage number exists
|
2001-11-26 18:20:38 +00:00
|
|
|
* @param err error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>
|
2000-12-08 21:36:47 +00:00
|
|
|
* @return the created Unicode converter object, or <TT>NULL</TT> if an error
|
|
|
|
* occured.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_open
|
|
|
|
* @see ucnv_openU
|
|
|
|
* @see ucnv_close
|
2001-03-17 01:36:48 +00:00
|
|
|
* @see ucnv_getCCSID
|
|
|
|
* @see ucnv_getPlatform
|
2000-12-08 21:36:47 +00:00
|
|
|
* @see UConverterPlatform
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE UConverter* U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_openCCSID(int32_t codepage,
|
|
|
|
UConverterPlatform platform,
|
|
|
|
UErrorCode * err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2002-07-17 02:34:50 +00:00
|
|
|
/**
|
|
|
|
* <p>Creates a UConverter object specified from a packageName and a converterName.</p>
|
|
|
|
*
|
|
|
|
* <p>The packageName and converterName must point to an ICU udata object, as defined by
|
|
|
|
* <code> udata_open( packageName, "cnv", converterName, err) </code> or equivalent.
|
|
|
|
* Typically, packageName will refer to a (.dat) file, or to a package registered with
|
2005-06-24 22:02:42 +00:00
|
|
|
* udata_setAppData(). Using a full file or directory pathname for packageName is deprecated.</p>
|
2002-07-17 02:34:50 +00:00
|
|
|
*
|
|
|
|
* <p>The name will NOT be looked up in the alias mechanism, nor will the converter be
|
|
|
|
* stored in the converter cache or the alias table. The only way to open further converters
|
|
|
|
* is call this function multiple times, or use the ucnv_safeClone() function to clone a
|
|
|
|
* 'master' converter.</p>
|
2003-11-18 02:37:24 +00:00
|
|
|
*
|
|
|
|
* <p>A future version of ICU may add alias table lookups and/or caching
|
|
|
|
* to this function.</p>
|
2002-07-17 02:34:50 +00:00
|
|
|
*
|
|
|
|
* <p>Example Use:
|
2003-02-03 22:34:59 +00:00
|
|
|
* <code>cnv = ucnv_openPackage("myapp", "myconverter", &err);</code>
|
2002-07-17 02:34:50 +00:00
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @param packageName name of the package (equivalent to 'path' in udata_open() call)
|
|
|
|
* @param converterName name of the data item to be used, without suffix.
|
|
|
|
* @param err outgoing error status <TT>U_MEMORY_ALLOCATION_ERROR, U_FILE_ACCESS_ERROR</TT>
|
|
|
|
* @return the created Unicode converter object, or <TT>NULL</TT> if an error occured
|
|
|
|
* @see udata_open
|
|
|
|
* @see ucnv_open
|
|
|
|
* @see ucnv_safeClone
|
|
|
|
* @see ucnv_close
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-07-17 02:34:50 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE UConverter* U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_openPackage(const char *packageName, const char *converterName, UErrorCode *err);
|
2002-07-17 02:34:50 +00:00
|
|
|
|
2001-02-16 22:21:14 +00:00
|
|
|
/**
|
2005-06-21 21:08:36 +00:00
|
|
|
* Thread safe converter cloning operation.
|
|
|
|
* For most efficient operation, pass in a stackBuffer (and a *pBufferSize)
|
|
|
|
* with at least U_CNV_SAFECLONE_BUFFERSIZE bytes of space.
|
|
|
|
* If the buffer size is sufficient, then the clone will use the stack buffer;
|
|
|
|
* otherwise, it will be allocated, and *pBufferSize will indicate
|
|
|
|
* the actual size. (This should not occur with U_CNV_SAFECLONE_BUFFERSIZE.)
|
|
|
|
*
|
|
|
|
* You must ucnv_close() the clone in any case.
|
|
|
|
*
|
|
|
|
* If *pBufferSize==0, (regardless of whether stackBuffer==NULL or not)
|
|
|
|
* then *pBufferSize will be changed to a sufficient size
|
|
|
|
* for cloning this converter,
|
|
|
|
* without actually cloning the converter ("pure pre-flighting").
|
|
|
|
*
|
|
|
|
* If *pBufferSize is greater than zero but not large enough for a stack-based
|
|
|
|
* clone, then the converter is cloned using newly allocated memory
|
|
|
|
* and *pBufferSize is changed to the necessary size.
|
|
|
|
*
|
|
|
|
* If the converter clone fits into the stack buffer but the stack buffer is not
|
|
|
|
* sufficiently aligned for the clone, then the clone will use an
|
|
|
|
* adjusted pointer and use an accordingly smaller buffer size.
|
|
|
|
*
|
2001-02-16 22:21:14 +00:00
|
|
|
* @param cnv converter to be cloned
|
|
|
|
* @param stackBuffer user allocated space for the new clone. If NULL new memory will be allocated.
|
2001-03-21 20:44:20 +00:00
|
|
|
* If buffer is not large enough, new memory will be allocated.
|
|
|
|
* Clients can use the U_CNV_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations.
|
2005-06-21 21:08:36 +00:00
|
|
|
* @param pBufferSize pointer to size of allocated space. pBufferSize must not be NULL.
|
2001-02-16 22:21:14 +00:00
|
|
|
* @param status to indicate whether the operation went on smoothly or there were errors
|
2005-06-21 21:08:36 +00:00
|
|
|
* An informational status value, U_SAFECLONE_ALLOCATED_WARNING,
|
|
|
|
* is used if any allocations were necessary.
|
|
|
|
* However, it is better to check if *pBufferSize grew for checking for
|
|
|
|
* allocations because warning codes can be overridden by subsequent
|
|
|
|
* function calls.
|
2001-02-16 22:21:14 +00:00
|
|
|
* @return pointer to the new clone
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-02-16 22:21:14 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE UConverter * U_EXPORT2
|
2001-03-21 20:44:20 +00:00
|
|
|
ucnv_safeClone(const UConverter *cnv,
|
|
|
|
void *stackBuffer,
|
|
|
|
int32_t *pBufferSize,
|
|
|
|
UErrorCode *status);
|
2001-02-16 22:21:14 +00:00
|
|
|
|
2003-12-16 05:16:55 +00:00
|
|
|
/**
|
|
|
|
* \def U_CNV_SAFECLONE_BUFFERSIZE
|
|
|
|
* Definition of a buffer size that is designed to be large enough for
|
|
|
|
* converters to be cloned with ucnv_safeClone().
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
2003-12-18 19:58:22 +00:00
|
|
|
#define U_CNV_SAFECLONE_BUFFERSIZE 1024
|
2001-02-16 22:21:14 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Deletes the unicode converter and releases resources associated
|
|
|
|
* with just this instance.
|
|
|
|
* Does not free up shared converter tables.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
|
|
|
* @param converter the converter object to be deleted
|
|
|
|
* @see ucnv_open
|
|
|
|
* @see ucnv_openU
|
|
|
|
* @see ucnv_openCCSID
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_close(UConverter * converter);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2009-12-17 07:13:28 +00:00
|
|
|
#if U_SHOW_CPLUSPLUS_API
|
2009-11-14 00:36:06 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \class LocalUConverterPointer
|
|
|
|
* "Smart pointer" class, closes a UConverter via ucnv_close().
|
|
|
|
* For most methods see the LocalPointerBase base class.
|
|
|
|
*
|
|
|
|
* @see LocalPointerBase
|
|
|
|
* @see LocalPointer
|
2010-11-15 19:40:24 +00:00
|
|
|
* @stable ICU 4.4
|
2009-11-14 00:36:06 +00:00
|
|
|
*/
|
|
|
|
U_DEFINE_LOCAL_OPEN_POINTER(LocalUConverterPointer, UConverter, ucnv_close);
|
|
|
|
|
|
|
|
U_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Fills in the output parameter, subChars, with the substitution characters
|
|
|
|
* as multiple bytes.
|
2006-07-05 23:08:50 +00:00
|
|
|
* If ucnv_setSubstString() set a Unicode string because the converter is
|
|
|
|
* stateful, then subChars will be an empty string.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param converter the Unicode converter
|
|
|
|
* @param subChars the subsitution characters
|
|
|
|
* @param len on input the capacity of subChars, on output the number
|
|
|
|
* of bytes copied to it
|
|
|
|
* @param err the outgoing error status code.
|
1999-12-28 23:39:02 +00:00
|
|
|
* If the substitution character array is too small, an
|
|
|
|
* <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
|
2006-07-05 23:08:50 +00:00
|
|
|
* @see ucnv_setSubstString
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_setSubstChars
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getSubstChars(const UConverter *converter,
|
|
|
|
char *subChars,
|
|
|
|
int8_t *len,
|
|
|
|
UErrorCode *err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the substitution chars when converting from unicode to a codepage. The
|
2000-12-08 21:36:47 +00:00
|
|
|
* substitution is specified as a string of 1-4 bytes, and may contain
|
2006-07-05 23:08:50 +00:00
|
|
|
* <TT>NULL</TT> bytes.
|
|
|
|
* The subChars must represent a single character. The caller needs to know the
|
|
|
|
* byte sequence of a valid character in the converter's charset.
|
|
|
|
* For some converters, for example some ISO 2022 variants, only single-byte
|
|
|
|
* substitution characters may be supported.
|
|
|
|
* The newer ucnv_setSubstString() function relaxes these limitations.
|
|
|
|
*
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param converter the Unicode converter
|
|
|
|
* @param subChars the substitution character byte sequence we want set
|
|
|
|
* @param len the number of bytes in subChars
|
|
|
|
* @param err the error status code. <TT>U_INDEX_OUTOFBOUNDS_ERROR </TT> if
|
|
|
|
* len is bigger than the maximum number of bytes allowed in subchars
|
2006-07-05 23:08:50 +00:00
|
|
|
* @see ucnv_setSubstString
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_getSubstChars
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_setSubstChars(UConverter *converter,
|
|
|
|
const char *subChars,
|
|
|
|
int8_t len,
|
|
|
|
UErrorCode *err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2006-07-05 23:08:50 +00:00
|
|
|
/**
|
|
|
|
* Set a substitution string for converting from Unicode to a charset.
|
|
|
|
* The caller need not know the charset byte sequence for each charset.
|
|
|
|
*
|
|
|
|
* Unlike ucnv_setSubstChars() which is designed to set a charset byte sequence
|
|
|
|
* for a single character, this function takes a Unicode string with
|
|
|
|
* zero, one or more characters, and immediately verifies that the string can be
|
|
|
|
* converted to the charset.
|
|
|
|
* If not, or if the result is too long (more than 32 bytes as of ICU 3.6),
|
|
|
|
* then the function returns with an error accordingly.
|
|
|
|
*
|
|
|
|
* Also unlike ucnv_setSubstChars(), this function works for stateful charsets
|
|
|
|
* by converting on the fly at the point of substitution rather than setting
|
|
|
|
* a fixed byte sequence.
|
|
|
|
*
|
|
|
|
* @param cnv The UConverter object.
|
|
|
|
* @param s The Unicode string.
|
|
|
|
* @param length The number of UChars in s, or -1 for a NUL-terminated string.
|
|
|
|
* @param err Pointer to a standard ICU error code. Its input value must
|
|
|
|
* pass the U_SUCCESS() test, or else the function returns
|
|
|
|
* immediately. Check for U_FAILURE() on output or use with
|
|
|
|
* function chaining. (See User Guide for details.)
|
|
|
|
*
|
|
|
|
* @see ucnv_setSubstChars
|
|
|
|
* @see ucnv_getSubstChars
|
2007-08-19 08:59:28 +00:00
|
|
|
* @stable ICU 3.6
|
2006-07-05 23:08:50 +00:00
|
|
|
*/
|
2007-08-19 08:59:28 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2006-07-05 23:08:50 +00:00
|
|
|
ucnv_setSubstString(UConverter *cnv,
|
|
|
|
const UChar *s,
|
|
|
|
int32_t length,
|
|
|
|
UErrorCode *err);
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Fills in the output parameter, errBytes, with the error characters from the
|
|
|
|
* last failing conversion.
|
|
|
|
*
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param converter the Unicode converter
|
|
|
|
* @param errBytes the codepage bytes which were in error
|
|
|
|
* @param len on input the capacity of errBytes, on output the number of
|
|
|
|
* bytes which were copied to it
|
|
|
|
* @param err the error status code.
|
1999-12-28 23:39:02 +00:00
|
|
|
* If the substitution character array is too small, an
|
|
|
|
* <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getInvalidChars(const UConverter *converter,
|
|
|
|
char *errBytes,
|
|
|
|
int8_t *len,
|
|
|
|
UErrorCode *err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fills in the output parameter, errChars, with the error characters from the
|
|
|
|
* last failing conversion.
|
|
|
|
*
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param converter the Unicode converter
|
|
|
|
* @param errUChars the UChars which were in error
|
|
|
|
* @param len on input the capacity of errUChars, on output the number of
|
|
|
|
* UChars which were copied to it
|
|
|
|
* @param err the error status code.
|
1999-12-28 23:39:02 +00:00
|
|
|
* If the substitution character array is too small, an
|
|
|
|
* <TT>U_INDEX_OUTOFBOUNDS_ERROR</TT> will be returned.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getInvalidUChars(const UConverter *converter,
|
|
|
|
UChar *errUChars,
|
|
|
|
int8_t *len,
|
|
|
|
UErrorCode *err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-11-17 02:40:07 +00:00
|
|
|
* Resets the state of a converter to the default state. This is used
|
2000-12-08 21:36:47 +00:00
|
|
|
* in the case of an error, to restart a conversion from a known default state.
|
2000-11-17 02:40:07 +00:00
|
|
|
* It will also empty the internal output buffers.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param converter the Unicode converter
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_reset(UConverter *converter);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-11-17 02:40:07 +00:00
|
|
|
/**
|
|
|
|
* Resets the to-Unicode part of a converter state to the default state.
|
|
|
|
* This is used in the case of an error to restart a conversion to
|
|
|
|
* Unicode to a known default state. It will also empty the internal
|
|
|
|
* output buffers used for the conversion to Unicode codepoints.
|
|
|
|
* @param converter the Unicode converter
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-11-17 02:40:07 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2000-12-08 21:36:47 +00:00
|
|
|
ucnv_resetToUnicode(UConverter *converter);
|
2000-11-17 02:40:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the from-Unicode part of a converter state to the default state.
|
|
|
|
* This is used in the case of an error to restart a conversion from
|
|
|
|
* Unicode to a known default state. It will also empty the internal output
|
|
|
|
* buffers used for the conversion from Unicode codepoints.
|
|
|
|
* @param converter the Unicode converter
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-11-17 02:40:07 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2000-12-08 21:36:47 +00:00
|
|
|
ucnv_resetFromUnicode(UConverter *converter);
|
2000-11-17 02:40:07 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2003-10-30 23:03:18 +00:00
|
|
|
* Returns the maximum number of bytes that are output per UChar in conversion
|
|
|
|
* from Unicode using this converter.
|
|
|
|
* The returned number can be used with UCNV_GET_MAX_BYTES_FOR_STRING
|
|
|
|
* to calculate the size of a target buffer for conversion from Unicode.
|
|
|
|
*
|
|
|
|
* Note: Before ICU 2.8, this function did not return reliable numbers for
|
|
|
|
* some stateful converters (EBCDIC_STATEFUL, ISO-2022) and LMBCS.
|
|
|
|
*
|
|
|
|
* This number may not be the same as the maximum number of bytes per
|
|
|
|
* "conversion unit". In other words, it may not be the intuitively expected
|
|
|
|
* number of bytes per character that would be published for a charset,
|
|
|
|
* and may not fulfill any other purpose than the allocation of an output
|
|
|
|
* buffer of guaranteed sufficient size for a given input length and converter.
|
|
|
|
*
|
|
|
|
* Examples for special cases that are taken into account:
|
|
|
|
* - Supplementary code points may convert to more bytes than BMP code points.
|
|
|
|
* This function returns bytes per UChar (UTF-16 code unit), not per
|
|
|
|
* Unicode code point, for efficient buffer allocation.
|
|
|
|
* - State-shifting output (SI/SO, escapes, etc.) from stateful converters.
|
|
|
|
* - When m input UChars are converted to n output bytes, then the maximum m/n
|
|
|
|
* is taken into account.
|
|
|
|
*
|
|
|
|
* The number returned here does not take into account
|
|
|
|
* (see UCNV_GET_MAX_BYTES_FOR_STRING):
|
|
|
|
* - callbacks which output more than one charset character sequence per call,
|
|
|
|
* like escape callbacks
|
|
|
|
* - initial and final non-character bytes that are output by some converters
|
|
|
|
* (automatic BOMs, initial escape sequence, final SI, etc.)
|
|
|
|
*
|
|
|
|
* Examples for returned values:
|
|
|
|
* - SBCS charsets: 1
|
|
|
|
* - Shift-JIS: 2
|
|
|
|
* - UTF-16: 2 (2 per BMP, 4 per surrogate _pair_, BOM not counted)
|
|
|
|
* - UTF-8: 3 (3 per BMP, 4 per surrogate _pair_)
|
|
|
|
* - EBCDIC_STATEFUL (EBCDIC mixed SBCS/DBCS): 3 (SO + DBCS)
|
|
|
|
* - ISO-2022: 3 (always outputs UTF-8)
|
|
|
|
* - ISO-2022-JP: 6 (4-byte escape sequences + DBCS)
|
|
|
|
* - ISO-2022-CN: 8 (4-byte designator sequences + 2-byte SS2/SS3 + DBCS)
|
|
|
|
*
|
|
|
|
* @param converter The Unicode converter.
|
|
|
|
* @return The maximum number of bytes per UChar that are output by ucnv_fromUnicode(),
|
|
|
|
* to be used together with UCNV_GET_MAX_BYTES_FOR_STRING for buffer allocation.
|
|
|
|
*
|
|
|
|
* @see UCNV_GET_MAX_BYTES_FOR_STRING
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_getMinCharSize
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE int8_t U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getMaxCharSize(const UConverter *converter);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2003-10-30 23:03:18 +00:00
|
|
|
/**
|
|
|
|
* Calculates the size of a buffer for conversion from Unicode to a charset.
|
|
|
|
* The calculated size is guaranteed to be sufficient for this conversion.
|
|
|
|
*
|
|
|
|
* It takes into account initial and final non-character bytes that are output
|
|
|
|
* by some converters.
|
|
|
|
* It does not take into account callbacks which output more than one charset
|
|
|
|
* character sequence per call, like escape callbacks.
|
|
|
|
* The default (substitution) callback only outputs one charset character sequence.
|
|
|
|
*
|
|
|
|
* @param length Number of UChars to be converted.
|
|
|
|
* @param maxCharSize Return value from ucnv_getMaxCharSize() for the converter
|
|
|
|
* that will be used.
|
|
|
|
* @return Size of a buffer that will be large enough to hold the output bytes of
|
|
|
|
* converting length UChars with the converter that returned the maxCharSize.
|
|
|
|
*
|
|
|
|
* @see ucnv_getMaxCharSize
|
2005-06-22 23:38:06 +00:00
|
|
|
* @stable ICU 2.8
|
2003-10-30 23:03:18 +00:00
|
|
|
*/
|
|
|
|
#define UCNV_GET_MAX_BYTES_FOR_STRING(length, maxCharSize) \
|
|
|
|
(((int32_t)(length)+10)*(int32_t)(maxCharSize))
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Returns the minimum byte length for characters in this codepage.
|
2003-10-30 23:03:18 +00:00
|
|
|
* This is usually either 1 or 2.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param converter the Unicode converter
|
|
|
|
* @return the minimum number of bytes allowed by this particular converter
|
|
|
|
* @see ucnv_getMaxCharSize
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE int8_t U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getMinCharSize(const UConverter *converter);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Returns the display name of the converter passed in based on the Locale
|
|
|
|
* passed in. If the locale contains no display name, the internal ASCII
|
|
|
|
* name will be filled in.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
|
|
|
* @param converter the Unicode converter.
|
|
|
|
* @param displayLocale is the specific Locale we want to localised for
|
|
|
|
* @param displayName user provided buffer to be filled in
|
2003-04-25 23:47:18 +00:00
|
|
|
* @param displayNameCapacity size of displayName Buffer
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param err error status code
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return displayNameLength number of UChar needed in displayName
|
|
|
|
* @see ucnv_getName
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getDisplayName(const UConverter *converter,
|
|
|
|
const char *displayLocale,
|
|
|
|
UChar *displayName,
|
|
|
|
int32_t displayNameCapacity,
|
|
|
|
UErrorCode *err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Gets the internal, canonical name of the converter (zero-terminated).
|
|
|
|
* The lifetime of the returned string will be that of the converter
|
|
|
|
* passed to this function.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param converter the Unicode converter
|
|
|
|
* @param err UErrorCode status
|
|
|
|
* @return the internal name of the converter
|
|
|
|
* @see ucnv_getDisplayName
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE const char * U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getName(const UConverter *converter, UErrorCode *err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a codepage number associated with the converter. This is not guaranteed
|
|
|
|
* to be the one used to create the converter. Some converters do not represent
|
2000-12-08 21:36:47 +00:00
|
|
|
* platform registered codepages and return zero for the codepage number.
|
|
|
|
* The error code fill-in parameter indicates if the codepage number
|
|
|
|
* is available.
|
|
|
|
* Does not check if the converter is <TT>NULL</TT> or if converter's data
|
|
|
|
* table is <TT>NULL</TT>.
|
2001-03-17 01:36:48 +00:00
|
|
|
*
|
|
|
|
* Important: The use of CCSIDs is not recommended because it is limited
|
|
|
|
* to only two platforms in principle and only one (UCNV_IBM) in the current
|
|
|
|
* ICU converter API.
|
|
|
|
* Also, CCSIDs are insufficient to identify IBM Unicode conversion tables precisely.
|
|
|
|
* For more details see ucnv_openCCSID().
|
|
|
|
*
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param converter the Unicode converter
|
|
|
|
* @param err the error status code.
|
|
|
|
* @return If any error occurrs, -1 will be returned otherwise, the codepage number
|
|
|
|
* will be returned
|
2001-03-17 01:36:48 +00:00
|
|
|
* @see ucnv_openCCSID
|
|
|
|
* @see ucnv_getPlatform
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getCCSID(const UConverter *converter,
|
|
|
|
UErrorCode *err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Gets a codepage platform associated with the converter. Currently,
|
|
|
|
* only <TT>UCNV_IBM</TT> will be returned.
|
|
|
|
* Does not test if the converter is <TT>NULL</TT> or if converter's data
|
|
|
|
* table is <TT>NULL</TT>.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param converter the Unicode converter
|
|
|
|
* @param err the error status code.
|
|
|
|
* @return The codepage platform
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE UConverterPlatform U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getPlatform(const UConverter *converter,
|
|
|
|
UErrorCode *err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Gets the type of the converter
|
|
|
|
* e.g. SBCS, MBCS, DBCS, UTF8, UTF16_BE, UTF16_LE, ISO_2022,
|
|
|
|
* EBCDIC_STATEFUL, LATIN_1
|
|
|
|
* @param converter a valid, opened converter
|
1999-12-28 23:39:02 +00:00
|
|
|
* @return the type of the converter
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE UConverterType U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getType(const UConverter * converter);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Gets the "starter" (lead) bytes for converters of type MBCS.
|
|
|
|
* Will fill in an <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> if converter passed in
|
|
|
|
* is not MBCS. Fills in an array of type UBool, with the value of the byte
|
|
|
|
* as offset to the array. For example, if (starters[0x20] == TRUE) at return,
|
|
|
|
* it means that the byte 0x20 is a starter byte in this converter.
|
|
|
|
* Context pointers are always owned by the caller.
|
|
|
|
*
|
|
|
|
* @param converter a valid, opened converter of type MBCS
|
|
|
|
* @param starters an array of size 256 to be filled in
|
|
|
|
* @param err error status, <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> if the
|
|
|
|
* converter is not a type which can return starters.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_getType
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getStarters(const UConverter* converter,
|
|
|
|
UBool starters[256],
|
|
|
|
UErrorCode* err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2004-03-26 19:42:04 +00:00
|
|
|
|
2003-04-09 22:40:58 +00:00
|
|
|
/**
|
|
|
|
* Selectors for Unicode sets that can be returned by ucnv_getUnicodeSet().
|
|
|
|
* @see ucnv_getUnicodeSet
|
2004-11-02 07:28:07 +00:00
|
|
|
* @stable ICU 2.6
|
2003-04-09 22:40:58 +00:00
|
|
|
*/
|
2005-06-28 22:23:05 +00:00
|
|
|
typedef enum UConverterUnicodeSet {
|
2004-11-02 07:28:07 +00:00
|
|
|
/** Select the set of roundtrippable Unicode code points. @stable ICU 2.6 */
|
2003-04-05 01:33:02 +00:00
|
|
|
UCNV_ROUNDTRIP_SET,
|
2009-03-19 04:03:31 +00:00
|
|
|
/** Select the set of Unicode code points with roundtrip or fallback mappings. @stable ICU 4.0 */
|
2007-10-24 21:15:41 +00:00
|
|
|
UCNV_ROUNDTRIP_AND_FALLBACK_SET,
|
2004-11-02 07:28:07 +00:00
|
|
|
/** Number of UConverterUnicodeSet selectors. @stable ICU 2.6 */
|
2003-04-05 01:33:02 +00:00
|
|
|
UCNV_SET_COUNT
|
|
|
|
} UConverterUnicodeSet;
|
|
|
|
|
2004-03-26 19:42:04 +00:00
|
|
|
|
2003-04-09 22:32:03 +00:00
|
|
|
/**
|
|
|
|
* Returns the set of Unicode code points that can be converted by an ICU converter.
|
|
|
|
*
|
2007-10-24 21:15:41 +00:00
|
|
|
* Returns one of several kinds of set:
|
|
|
|
*
|
|
|
|
* 1. UCNV_ROUNDTRIP_SET
|
|
|
|
*
|
2003-04-09 22:32:03 +00:00
|
|
|
* The set of all Unicode code points that can be roundtrip-converted
|
2007-10-24 21:15:41 +00:00
|
|
|
* (converted without any data loss) with the converter (ucnv_fromUnicode()).
|
2003-04-09 22:32:03 +00:00
|
|
|
* This set will not include code points that have fallback mappings
|
|
|
|
* or are only the result of reverse fallback mappings.
|
2007-10-24 21:15:41 +00:00
|
|
|
* This set will also not include PUA code points with fallbacks, although
|
|
|
|
* ucnv_fromUnicode() will always uses those mappings despite ucnv_setFallback().
|
2003-04-09 22:32:03 +00:00
|
|
|
* See UTR #22 "Character Mapping Markup Language"
|
|
|
|
* at http://www.unicode.org/reports/tr22/
|
|
|
|
*
|
|
|
|
* This is useful for example for
|
|
|
|
* - checking that a string or document can be roundtrip-converted with a converter,
|
|
|
|
* without/before actually performing the conversion
|
|
|
|
* - testing if a converter can be used for text for typical text for a certain locale,
|
|
|
|
* by comparing its roundtrip set with the set of ExemplarCharacters from
|
|
|
|
* ICU's locale data or other sources
|
|
|
|
*
|
2007-10-24 21:15:41 +00:00
|
|
|
* 2. UCNV_ROUNDTRIP_AND_FALLBACK_SET
|
|
|
|
*
|
|
|
|
* The set of all Unicode code points that can be converted with the converter (ucnv_fromUnicode())
|
|
|
|
* when fallbacks are turned on (see ucnv_setFallback()).
|
|
|
|
* This set includes all code points with roundtrips and fallbacks (but not reverse fallbacks).
|
|
|
|
*
|
2003-04-09 22:32:03 +00:00
|
|
|
* In the future, there may be more UConverterUnicodeSet choices to select
|
|
|
|
* sets with different properties.
|
|
|
|
*
|
|
|
|
* @param cnv The converter for which a set is requested.
|
2004-05-13 21:21:58 +00:00
|
|
|
* @param setFillIn A valid USet *. It will be cleared by this function before
|
2003-04-09 22:32:03 +00:00
|
|
|
* the converter's specific set is filled into the USet.
|
2004-05-13 21:21:58 +00:00
|
|
|
* @param whichSet A UConverterUnicodeSet selector;
|
2003-04-09 22:32:03 +00:00
|
|
|
* currently UCNV_ROUNDTRIP_SET is the only supported value.
|
|
|
|
* @param pErrorCode ICU error code in/out parameter.
|
|
|
|
* Must fulfill U_SUCCESS before the function call.
|
|
|
|
*
|
|
|
|
* @see UConverterUnicodeSet
|
|
|
|
* @see uset_open
|
|
|
|
* @see uset_close
|
2004-11-02 07:28:07 +00:00
|
|
|
* @stable ICU 2.6
|
2003-04-09 22:32:03 +00:00
|
|
|
*/
|
2004-11-02 07:28:07 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2003-04-05 01:33:02 +00:00
|
|
|
ucnv_getUnicodeSet(const UConverter *cnv,
|
2004-05-13 21:21:58 +00:00
|
|
|
USet *setFillIn,
|
|
|
|
UConverterUnicodeSet whichSet,
|
2003-04-05 01:33:02 +00:00
|
|
|
UErrorCode *pErrorCode);
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Gets the current calback function used by the converter when an illegal
|
|
|
|
* or invalid codepage sequence is found.
|
|
|
|
* Context pointers are always owned by the caller.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
|
|
|
* @param converter the unicode converter
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param action fillin: returns the callback function pointer
|
|
|
|
* @param context fillin: returns the callback's private void* context
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_setToUCallBack
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2000-12-08 21:36:47 +00:00
|
|
|
ucnv_getToUCallBack (const UConverter * converter,
|
|
|
|
UConverterToUCallback *action,
|
2001-06-26 22:51:14 +00:00
|
|
|
const void **context);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Gets the current callback function used by the converter when illegal
|
|
|
|
* or invalid Unicode sequence is found.
|
|
|
|
* Context pointers are always owned by the caller.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
|
|
|
* @param converter the unicode converter
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param action fillin: returns the callback function pointer
|
|
|
|
* @param context fillin: returns the callback's private void* context
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_setFromUCallBack
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2000-12-08 21:36:47 +00:00
|
|
|
ucnv_getFromUCallBack (const UConverter * converter,
|
|
|
|
UConverterFromUCallback *action,
|
2001-06-26 22:51:14 +00:00
|
|
|
const void **context);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Changes the callback function used by the converter when
|
|
|
|
* an illegal or invalid sequence is found.
|
|
|
|
* Context pointers are always owned by the caller.
|
2003-04-16 22:39:22 +00:00
|
|
|
* Predefined actions and contexts can be found in the ucnv_err.h header.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
|
|
|
* @param converter the unicode converter
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param newAction the new callback function
|
2003-04-16 22:39:22 +00:00
|
|
|
* @param newContext the new toUnicode callback context pointer. This can be NULL.
|
|
|
|
* @param oldAction fillin: returns the old callback function pointer. This can be NULL.
|
|
|
|
* @param oldContext fillin: returns the old callback's private void* context. This can be NULL.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param err The error code status
|
|
|
|
* @see ucnv_getToUCallBack
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2000-12-08 21:36:47 +00:00
|
|
|
ucnv_setToUCallBack (UConverter * converter,
|
|
|
|
UConverterToUCallback newAction,
|
2001-06-26 22:51:14 +00:00
|
|
|
const void* newContext,
|
2000-12-08 21:36:47 +00:00
|
|
|
UConverterToUCallback *oldAction,
|
2001-06-26 22:51:14 +00:00
|
|
|
const void** oldContext,
|
2000-12-08 21:36:47 +00:00
|
|
|
UErrorCode * err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Changes the current callback function used by the converter when
|
|
|
|
* an illegal or invalid sequence is found.
|
|
|
|
* Context pointers are always owned by the caller.
|
2003-04-16 22:39:22 +00:00
|
|
|
* Predefined actions and contexts can be found in the ucnv_err.h header.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
|
|
|
* @param converter the unicode converter
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param newAction the new callback function
|
2003-04-16 22:39:22 +00:00
|
|
|
* @param newContext the new fromUnicode callback context pointer. This can be NULL.
|
|
|
|
* @param oldAction fillin: returns the old callback function pointer. This can be NULL.
|
|
|
|
* @param oldContext fillin: returns the old callback's private void* context. This can be NULL.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param err The error code status
|
|
|
|
* @see ucnv_getFromUCallBack
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2000-12-08 21:36:47 +00:00
|
|
|
ucnv_setFromUCallBack (UConverter * converter,
|
|
|
|
UConverterFromUCallback newAction,
|
2001-06-26 22:51:14 +00:00
|
|
|
const void *newContext,
|
2000-12-08 21:36:47 +00:00
|
|
|
UConverterFromUCallback *oldAction,
|
2001-06-26 22:51:14 +00:00
|
|
|
const void **oldContext,
|
2000-12-08 21:36:47 +00:00
|
|
|
UErrorCode * err);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts an array of unicode characters to an array of codepage
|
|
|
|
* characters. This function is optimized for converting a continuous
|
|
|
|
* stream of data in buffer-sized chunks, where the entire source and
|
|
|
|
* target does not fit in available buffers.
|
|
|
|
*
|
|
|
|
* The source pointer is an in/out parameter. It starts out pointing where the
|
|
|
|
* conversion is to begin, and ends up pointing after the last UChar consumed.
|
|
|
|
*
|
|
|
|
* Target similarly starts out pointer at the first available byte in the output
|
|
|
|
* buffer, and ends up pointing after the last byte written to the output.
|
|
|
|
*
|
|
|
|
* The converter always attempts to consume the entire source buffer, unless
|
|
|
|
* (1.) the target buffer is full, or (2.) a failing error is returned from the
|
|
|
|
* current callback function. When a successful error status has been
|
|
|
|
* returned, it means that all of the source buffer has been
|
|
|
|
* consumed. At that point, the caller should reset the source and
|
|
|
|
* sourceLimit pointers to point to the next chunk.
|
|
|
|
*
|
2003-10-31 04:59:36 +00:00
|
|
|
* At the end of the stream (flush==TRUE), the input is completely consumed
|
|
|
|
* when *source==sourceLimit and no error code is set.
|
|
|
|
* The converter object is then automatically reset by this function.
|
|
|
|
* (This means that a converter need not be reset explicitly between data
|
|
|
|
* streams if it finishes the previous stream without errors.)
|
|
|
|
*
|
2000-12-08 21:36:47 +00:00
|
|
|
* This is a <I>stateful</I> conversion. Additionally, even when all source data has
|
|
|
|
* been consumed, some data may be in the converters' internal state.
|
|
|
|
* Call this function repeatedly, updating the target pointers with
|
|
|
|
* the next empty chunk of target in case of a
|
|
|
|
* <TT>U_BUFFER_OVERFLOW_ERROR</TT>, and updating the source pointers
|
|
|
|
* with the next chunk of source when a successful error status is
|
|
|
|
* returned, until there are no more chunks of source data.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param converter the Unicode converter
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param target I/O parameter. Input : Points to the beginning of the buffer to copy
|
1999-12-28 23:39:02 +00:00
|
|
|
* codepage characters to. Output : points to after the last codepage character copied
|
|
|
|
* to <TT>target</TT>.
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param targetLimit the pointer just after last of the <TT>target</TT> buffer
|
|
|
|
* @param source I/O parameter, pointer to pointer to the source Unicode character buffer.
|
|
|
|
* @param sourceLimit the pointer just after the last of the source buffer
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number
|
|
|
|
* of allocated cells as <TT>target</TT>. Will fill in offsets from target to source pointer
|
|
|
|
* 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>
|
2000-12-08 21:36:47 +00:00
|
|
|
* For output data carried across calls, and other data without a specific source character
|
|
|
|
* (such as from escape sequences or callbacks) -1 will be placed for offsets.
|
|
|
|
* @param flush set to <TT>TRUE</TT> if the current source buffer is the last available
|
|
|
|
* chunk of the source, <TT>FALSE</TT> otherwise. Note that if a failing status is returned,
|
2002-08-27 23:01:04 +00:00
|
|
|
* this function may have to be called multiple times with flush set to <TT>TRUE</TT> until
|
2000-12-08 21:36:47 +00:00
|
|
|
* the source buffer is consumed.
|
2000-08-11 19:23:50 +00:00
|
|
|
* @param err the error status. <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> will be set if the
|
1999-12-28 23:39:02 +00:00
|
|
|
* converter is <TT>NULL</TT>.
|
2000-12-08 21:36:47 +00:00
|
|
|
* <code>U_BUFFER_OVERFLOW_ERROR</code> will be set if the target is full and there is
|
|
|
|
* still data to be written to the target.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_fromUChars
|
|
|
|
* @see ucnv_convert
|
|
|
|
* @see ucnv_getMinCharSize
|
|
|
|
* @see ucnv_setToUCallBack
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2000-12-08 21:36:47 +00:00
|
|
|
ucnv_fromUnicode (UConverter * converter,
|
|
|
|
char **target,
|
|
|
|
const char *targetLimit,
|
|
|
|
const UChar ** source,
|
|
|
|
const UChar * sourceLimit,
|
|
|
|
int32_t* offsets,
|
|
|
|
UBool flush,
|
|
|
|
UErrorCode * err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Converts a buffer of codepage bytes into an array of unicode UChars
|
|
|
|
* characters. This function is optimized for converting a continuous
|
|
|
|
* stream of data in buffer-sized chunks, where the entire source and
|
|
|
|
* target does not fit in available buffers.
|
|
|
|
*
|
|
|
|
* The source pointer is an in/out parameter. It starts out pointing where the
|
|
|
|
* conversion is to begin, and ends up pointing after the last byte of source consumed.
|
|
|
|
*
|
|
|
|
* Target similarly starts out pointer at the first available UChar in the output
|
|
|
|
* buffer, and ends up pointing after the last UChar written to the output.
|
|
|
|
* It does NOT necessarily keep UChar sequences together.
|
|
|
|
*
|
|
|
|
* The converter always attempts to consume the entire source buffer, unless
|
|
|
|
* (1.) the target buffer is full, or (2.) a failing error is returned from the
|
|
|
|
* current callback function. When a successful error status has been
|
|
|
|
* returned, it means that all of the source buffer has been
|
|
|
|
* consumed. At that point, the caller should reset the source and
|
|
|
|
* sourceLimit pointers to point to the next chunk.
|
2003-10-31 04:59:36 +00:00
|
|
|
*
|
|
|
|
* At the end of the stream (flush==TRUE), the input is completely consumed
|
|
|
|
* when *source==sourceLimit and no error code is set
|
|
|
|
* The converter object is then automatically reset by this function.
|
|
|
|
* (This means that a converter need not be reset explicitly between data
|
|
|
|
* streams if it finishes the previous stream without errors.)
|
2000-12-08 21:36:47 +00:00
|
|
|
*
|
|
|
|
* This is a <I>stateful</I> conversion. Additionally, even when all source data has
|
|
|
|
* been consumed, some data may be in the converters' internal state.
|
|
|
|
* Call this function repeatedly, updating the target pointers with
|
|
|
|
* the next empty chunk of target in case of a
|
|
|
|
* <TT>U_BUFFER_OVERFLOW_ERROR</TT>, and updating the source pointers
|
|
|
|
* with the next chunk of source when a successful error status is
|
|
|
|
* returned, until there are no more chunks of source data.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param converter the Unicode converter
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param target I/O parameter. Input : Points to the beginning of the buffer to copy
|
|
|
|
* UChars into. Output : points to after the last UChar copied.
|
|
|
|
* @param targetLimit the pointer just after the end of the <TT>target</TT> buffer
|
|
|
|
* @param source I/O parameter, pointer to pointer to the source codepage buffer.
|
|
|
|
* @param sourceLimit the pointer to the byte after the end of the source buffer
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param offsets if NULL is passed, nothing will happen to it, otherwise it needs to have the same number
|
|
|
|
* of allocated cells as <TT>target</TT>. Will fill in offsets from target to source pointer
|
|
|
|
* 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>
|
2000-12-08 21:36:47 +00:00
|
|
|
* For output data carried across calls, and other data without a specific source character
|
|
|
|
* (such as from escape sequences or callbacks) -1 will be placed for offsets.
|
|
|
|
* @param flush set to <TT>TRUE</TT> if the current source buffer is the last available
|
|
|
|
* chunk of the source, <TT>FALSE</TT> otherwise. Note that if a failing status is returned,
|
2002-08-27 23:01:04 +00:00
|
|
|
* this function may have to be called multiple times with flush set to <TT>TRUE</TT> until
|
2000-12-08 21:36:47 +00:00
|
|
|
* the source buffer is consumed.
|
|
|
|
* @param err the error status. <TT>U_ILLEGAL_ARGUMENT_ERROR</TT> will be set if the
|
|
|
|
* converter is <TT>NULL</TT>.
|
|
|
|
* <code>U_BUFFER_OVERFLOW_ERROR</code> will be set if the target is full and there is
|
|
|
|
* still data to be written to the target.
|
|
|
|
* @see ucnv_fromUChars
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_convert
|
2000-12-08 21:36:47 +00:00
|
|
|
* @see ucnv_getMinCharSize
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_setFromUCallBack
|
2000-12-08 21:36:47 +00:00
|
|
|
* @see ucnv_getNextUChar
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_toUnicode(UConverter *converter,
|
|
|
|
UChar **target,
|
|
|
|
const UChar *targetLimit,
|
|
|
|
const char **source,
|
|
|
|
const char *sourceLimit,
|
|
|
|
int32_t *offsets,
|
|
|
|
UBool flush,
|
|
|
|
UErrorCode *err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2001-09-28 22:22:59 +00:00
|
|
|
* Convert the Unicode string into a codepage string using an existing UConverter.
|
|
|
|
* The output string is NUL-terminated if possible.
|
|
|
|
*
|
|
|
|
* This function is a more convenient but less powerful version of ucnv_fromUnicode().
|
|
|
|
* It is only useful for whole strings, not for streaming conversion.
|
|
|
|
*
|
|
|
|
* The maximum output buffer capacity required (barring output from callbacks) will be
|
2003-10-30 23:03:18 +00:00
|
|
|
* UCNV_GET_MAX_BYTES_FOR_STRING(srcLength, ucnv_getMaxCharSize(cnv)).
|
2001-09-28 22:22:59 +00:00
|
|
|
*
|
|
|
|
* @param cnv the converter object to be used (ucnv_resetFromUnicode() will be called)
|
|
|
|
* @param src the input Unicode string
|
|
|
|
* @param srcLength the input string length, or -1 if NUL-terminated
|
|
|
|
* @param dest destination string buffer, can be NULL if destCapacity==0
|
|
|
|
* @param destCapacity the number of chars available at dest
|
2003-04-25 23:47:18 +00:00
|
|
|
* @param pErrorCode normal ICU error code;
|
2001-09-28 22:22:59 +00:00
|
|
|
* common error codes that may be set by this function include
|
|
|
|
* U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING,
|
|
|
|
* U_ILLEGAL_ARGUMENT_ERROR, and conversion errors
|
2007-08-31 19:39:14 +00:00
|
|
|
* @return the length of the output string, not counting the terminating NUL;
|
|
|
|
* if the length is greater than destCapacity, then the string will not fit
|
|
|
|
* and a buffer of the indicated length would need to be passed in
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_fromUnicode
|
|
|
|
* @see ucnv_convert
|
2003-10-30 23:03:18 +00:00
|
|
|
* @see UCNV_GET_MAX_BYTES_FOR_STRING
|
2002-12-05 00:30:16 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2001-09-28 22:22:59 +00:00
|
|
|
ucnv_fromUChars(UConverter *cnv,
|
|
|
|
char *dest, int32_t destCapacity,
|
|
|
|
const UChar *src, int32_t srcLength,
|
|
|
|
UErrorCode *pErrorCode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert the codepage string into a Unicode string using an existing UConverter.
|
|
|
|
* The output string is NUL-terminated if possible.
|
|
|
|
*
|
|
|
|
* This function is a more convenient but less powerful version of ucnv_toUnicode().
|
|
|
|
* It is only useful for whole strings, not for streaming conversion.
|
|
|
|
*
|
|
|
|
* The maximum output buffer capacity required (barring output from callbacks) will be
|
|
|
|
* 2*srcLength (each char may be converted into a surrogate pair).
|
|
|
|
*
|
|
|
|
* @param cnv the converter object to be used (ucnv_resetToUnicode() will be called)
|
|
|
|
* @param src the input codepage string
|
|
|
|
* @param srcLength the input string length, or -1 if NUL-terminated
|
|
|
|
* @param dest destination string buffer, can be NULL if destCapacity==0
|
|
|
|
* @param destCapacity the number of UChars available at dest
|
2003-04-25 23:47:18 +00:00
|
|
|
* @param pErrorCode normal ICU error code;
|
2001-09-28 22:22:59 +00:00
|
|
|
* common error codes that may be set by this function include
|
|
|
|
* U_BUFFER_OVERFLOW_ERROR, U_STRING_NOT_TERMINATED_WARNING,
|
|
|
|
* U_ILLEGAL_ARGUMENT_ERROR, and conversion errors
|
|
|
|
* @return the length of the output string, not counting the terminating NUL;
|
|
|
|
* if the length is greater than destCapacity, then the string will not fit
|
|
|
|
* and a buffer of the indicated length would need to be passed in
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_toUnicode
|
|
|
|
* @see ucnv_convert
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2001-09-28 22:22:59 +00:00
|
|
|
ucnv_toUChars(UConverter *cnv,
|
|
|
|
UChar *dest, int32_t destCapacity,
|
|
|
|
const char *src, int32_t srcLength,
|
|
|
|
UErrorCode *pErrorCode);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2001-11-09 18:17:40 +00:00
|
|
|
/**
|
2003-08-01 14:37:11 +00:00
|
|
|
* Convert a codepage buffer into Unicode one character at a time.
|
2003-10-31 04:59:36 +00:00
|
|
|
* The input is completely consumed when the U_INDEX_OUTOFBOUNDS_ERROR is set.
|
2003-08-01 14:37:11 +00:00
|
|
|
*
|
|
|
|
* Advantage compared to ucnv_toUnicode() or ucnv_toUChars():
|
|
|
|
* - Faster for small amounts of data, for most converters, e.g.,
|
|
|
|
* US-ASCII, ISO-8859-1, UTF-8/16/32, and most "normal" charsets.
|
|
|
|
* (For complex converters, e.g., SCSU, UTF-7 and ISO 2022 variants,
|
|
|
|
* it uses ucnv_toUnicode() internally.)
|
|
|
|
* - Convenient.
|
|
|
|
*
|
|
|
|
* Limitations compared to ucnv_toUnicode():
|
|
|
|
* - Always assumes flush=TRUE.
|
|
|
|
* This makes ucnv_getNextUChar() unsuitable for "streaming" conversion,
|
|
|
|
* that is, for where the input is supplied in multiple buffers,
|
|
|
|
* because ucnv_getNextUChar() will assume the end of the input at the end
|
|
|
|
* of the first buffer.
|
|
|
|
* - Does not provide offset output.
|
|
|
|
*
|
|
|
|
* It is possible to "mix" ucnv_getNextUChar() and ucnv_toUnicode() because
|
|
|
|
* ucnv_getNextUChar() uses the current state of the converter
|
|
|
|
* (unlike ucnv_toUChars() which always resets first).
|
|
|
|
* However, if ucnv_getNextUChar() is called after ucnv_toUnicode()
|
|
|
|
* stopped in the middle of a character sequence (with flush=FALSE),
|
|
|
|
* then ucnv_getNextUChar() will always use the slower ucnv_toUnicode()
|
|
|
|
* internally until the next character boundary.
|
|
|
|
* (This is new in ICU 2.6. In earlier releases, ucnv_getNextUChar() had to
|
|
|
|
* start at a character boundary.)
|
|
|
|
*
|
|
|
|
* Instead of using ucnv_getNextUChar(), it is recommended
|
|
|
|
* to convert using ucnv_toUnicode() or ucnv_toUChars()
|
|
|
|
* and then iterate over the text using U16_NEXT() or a UCharIterator (uiter.h)
|
|
|
|
* or a C++ CharacterIterator or similar.
|
|
|
|
* This allows streaming conversion and offset output, for example.
|
2000-10-26 20:09:17 +00:00
|
|
|
*
|
|
|
|
* <p>Handling of surrogate pairs and supplementary-plane code points:<br>
|
|
|
|
* There are two different kinds of codepages that provide mappings for surrogate characters:
|
|
|
|
* <ul>
|
|
|
|
* <li>Codepages like UTF-8, UTF-32, and GB 18030 provide direct representations for Unicode
|
|
|
|
* code points U+10000-U+10ffff as well as for single surrogates U+d800-U+dfff.
|
|
|
|
* Each valid sequence will result in exactly one returned code point.
|
|
|
|
* If a sequence results in a single surrogate, then that will be returned
|
|
|
|
* by itself, even if a neighboring sequence encodes the matching surrogate.</li>
|
|
|
|
* <li>Codepages like SCSU and LMBCS (and UTF-16) provide direct representations only for BMP code points
|
|
|
|
* including surrogates. Code points in supplementary planes are represented with
|
|
|
|
* two sequences, each encoding a surrogate.
|
|
|
|
* For these codepages, matching pairs of surrogates will be combined into single
|
|
|
|
* code points for returning from this function.
|
|
|
|
* (Note that SCSU is actually a mix of these codepage types.)</li>
|
|
|
|
* </ul></p>
|
|
|
|
*
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param converter an open UConverter
|
|
|
|
* @param source the address of a pointer to the codepage buffer, will be
|
|
|
|
* updated to point after the bytes consumed in the conversion call.
|
|
|
|
* @param sourceLimit points to the end of the input buffer
|
|
|
|
* @param err fills in error status (see ucnv_toUnicode)
|
|
|
|
* <code>U_INDEX_OUTOFBOUNDS_ERROR</code> will be set if the input
|
|
|
|
* is empty or does not convert to any output (e.g.: pure state-change
|
|
|
|
* codes SI/SO, escape sequences for ISO 2022,
|
|
|
|
* or if the callback did not output anything, ...).
|
|
|
|
* This function will not set a <code>U_BUFFER_OVERFLOW_ERROR</code> because
|
|
|
|
* the "buffer" is the return code. However, there might be subsequent output
|
|
|
|
* stored in the converter object
|
2000-08-11 19:23:50 +00:00
|
|
|
* that will be returned in following calls to this function.
|
2000-12-08 21:36:47 +00:00
|
|
|
* @return a UChar32 resulting from the partial conversion of source
|
|
|
|
* @see ucnv_toUnicode
|
|
|
|
* @see ucnv_toUChars
|
|
|
|
* @see ucnv_convert
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE UChar32 U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getNextUChar(UConverter * converter,
|
|
|
|
const char **source,
|
|
|
|
const char * sourceLimit,
|
|
|
|
UErrorCode * err);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2003-04-18 23:11:39 +00:00
|
|
|
/**
|
|
|
|
* Convert from one external charset to another using two existing UConverters.
|
|
|
|
* Internally, two conversions - ucnv_toUnicode() and ucnv_fromUnicode() -
|
|
|
|
* are used, "pivoting" through 16-bit Unicode.
|
|
|
|
*
|
2006-06-16 21:55:52 +00:00
|
|
|
* Important: For streaming conversion (multiple function calls for successive
|
|
|
|
* parts of a text stream), the caller must provide a pivot buffer explicitly,
|
|
|
|
* and must preserve the pivot buffer and associated pointers from one
|
|
|
|
* call to another. (The buffer may be moved if its contents and the relative
|
|
|
|
* pointer positions are preserved.)
|
|
|
|
*
|
2003-04-18 23:11:39 +00:00
|
|
|
* There is a similar function, ucnv_convert(),
|
|
|
|
* which has the following limitations:
|
|
|
|
* - it takes charset names, not converter objects, so that
|
|
|
|
* - two converters are opened for each call
|
|
|
|
* - only single-string conversion is possible, not streaming operation
|
|
|
|
* - it does not provide enough information to find out,
|
|
|
|
* in case of failure, whether the toUnicode or
|
|
|
|
* the fromUnicode conversion failed
|
|
|
|
*
|
|
|
|
* By contrast, ucnv_convertEx()
|
|
|
|
* - takes UConverter parameters instead of charset names
|
2006-06-16 21:55:52 +00:00
|
|
|
* - fully exposes the pivot buffer for streaming conversion and complete error handling
|
2003-04-18 23:11:39 +00:00
|
|
|
*
|
|
|
|
* ucnv_convertEx() also provides further convenience:
|
|
|
|
* - an option to reset the converters at the beginning
|
|
|
|
* (if reset==TRUE, see parameters;
|
|
|
|
* also sets *pivotTarget=*pivotSource=pivotStart)
|
|
|
|
* - allow NUL-terminated input
|
|
|
|
* (only a single NUL byte, will not work for charsets with multi-byte NULs)
|
|
|
|
* (if sourceLimit==NULL, see parameters)
|
|
|
|
* - terminate with a NUL on output
|
|
|
|
* (only a single NUL byte, not useful for charsets with multi-byte NULs),
|
|
|
|
* or set U_STRING_NOT_TERMINATED_WARNING if the output exactly fills
|
|
|
|
* the target buffer
|
|
|
|
* - the pivot buffer can be provided internally;
|
2006-06-16 21:55:52 +00:00
|
|
|
* possible only for whole-string conversion, not streaming conversion;
|
2003-04-18 23:11:39 +00:00
|
|
|
* in this case, the caller will not be able to get details about where an
|
|
|
|
* error occurred
|
|
|
|
* (if pivotStart==NULL, see below)
|
|
|
|
*
|
|
|
|
* The function returns when one of the following is true:
|
|
|
|
* - the entire source text has been converted successfully to the target buffer
|
|
|
|
* - a target buffer overflow occurred (U_BUFFER_OVERFLOW_ERROR)
|
|
|
|
* - a conversion error occurred
|
|
|
|
* (other U_FAILURE(), see description of pErrorCode)
|
|
|
|
*
|
|
|
|
* Limitation compared to the direct use of
|
|
|
|
* ucnv_fromUnicode() and ucnv_toUnicode():
|
|
|
|
* ucnv_convertEx() does not provide offset information.
|
|
|
|
*
|
|
|
|
* Limitation compared to ucnv_fromUChars() and ucnv_toUChars():
|
|
|
|
* ucnv_convertEx() does not support preflighting directly.
|
|
|
|
*
|
|
|
|
* Sample code for converting a single string from
|
|
|
|
* one external charset to UTF-8, ignoring the location of errors:
|
|
|
|
*
|
|
|
|
* \code
|
|
|
|
* int32_t
|
|
|
|
* myToUTF8(UConverter *cnv,
|
|
|
|
* const char *s, int32_t length,
|
|
|
|
* char *u8, int32_t capacity,
|
|
|
|
* UErrorCode *pErrorCode) {
|
|
|
|
* UConverter *utf8Cnv;
|
|
|
|
* char *target;
|
|
|
|
*
|
|
|
|
* if(U_FAILURE(*pErrorCode)) {
|
|
|
|
* return 0;
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* utf8Cnv=myGetCachedUTF8Converter(pErrorCode);
|
|
|
|
* if(U_FAILURE(*pErrorCode)) {
|
|
|
|
* return 0;
|
|
|
|
* }
|
|
|
|
*
|
2007-08-24 16:39:15 +00:00
|
|
|
* if(length<0) {
|
|
|
|
* length=strlen(s);
|
|
|
|
* }
|
2003-04-18 23:11:39 +00:00
|
|
|
* target=u8;
|
2009-04-23 15:39:39 +00:00
|
|
|
* ucnv_convertEx(utf8Cnv, cnv,
|
2003-04-18 23:11:39 +00:00
|
|
|
* &target, u8+capacity,
|
2007-08-24 16:39:15 +00:00
|
|
|
* &s, s+length,
|
2003-04-18 23:11:39 +00:00
|
|
|
* NULL, NULL, NULL, NULL,
|
|
|
|
* TRUE, TRUE,
|
|
|
|
* pErrorCode);
|
|
|
|
*
|
|
|
|
* myReleaseCachedUTF8Converter(utf8Cnv);
|
|
|
|
*
|
|
|
|
* // return the output string length, but without preflighting
|
|
|
|
* return (int32_t)(target-u8);
|
|
|
|
* }
|
|
|
|
* \endcode
|
|
|
|
*
|
|
|
|
* @param targetCnv Output converter, used to convert from the UTF-16 pivot
|
|
|
|
* to the target using ucnv_fromUnicode().
|
|
|
|
* @param sourceCnv Input converter, used to convert from the source to
|
|
|
|
* the UTF-16 pivot using ucnv_toUnicode().
|
|
|
|
* @param target I/O parameter, same as for ucnv_fromUChars().
|
|
|
|
* Input: *target points to the beginning of the target buffer.
|
|
|
|
* Output: *target points to the first unit after the last char written.
|
|
|
|
* @param targetLimit Pointer to the first unit after the target buffer.
|
|
|
|
* @param source I/O parameter, same as for ucnv_toUChars().
|
|
|
|
* Input: *source points to the beginning of the source buffer.
|
|
|
|
* Output: *source points to the first unit after the last char read.
|
|
|
|
* @param sourceLimit Pointer to the first unit after the source buffer.
|
|
|
|
* @param pivotStart Pointer to the UTF-16 pivot buffer. If pivotStart==NULL,
|
|
|
|
* then an internal buffer is used and the other pivot
|
|
|
|
* arguments are ignored and can be NULL as well.
|
|
|
|
* @param pivotSource I/O parameter, same as source in ucnv_fromUChars() for
|
|
|
|
* conversion from the pivot buffer to the target buffer.
|
|
|
|
* @param pivotTarget I/O parameter, same as target in ucnv_toUChars() for
|
|
|
|
* conversion from the source buffer to the pivot buffer.
|
|
|
|
* It must be pivotStart<=*pivotSource<=*pivotTarget<=pivotLimit
|
|
|
|
* and pivotStart<pivotLimit (unless pivotStart==NULL).
|
|
|
|
* @param pivotLimit Pointer to the first unit after the pivot buffer.
|
|
|
|
* @param reset If TRUE, then ucnv_resetToUnicode(sourceCnv) and
|
|
|
|
* ucnv_resetFromUnicode(targetCnv) are called, and the
|
|
|
|
* pivot pointers are reset (*pivotTarget=*pivotSource=pivotStart).
|
|
|
|
* @param flush If true, indicates the end of the input.
|
|
|
|
* Passed directly to ucnv_toUnicode(), and carried over to
|
|
|
|
* ucnv_fromUnicode() when the source is empty as well.
|
|
|
|
* @param pErrorCode ICU error code in/out parameter.
|
|
|
|
* Must fulfill U_SUCCESS before the function call.
|
|
|
|
* U_BUFFER_OVERFLOW_ERROR always refers to the target buffer
|
|
|
|
* because overflows into the pivot buffer are handled internally.
|
|
|
|
* Other conversion errors are from the source-to-pivot
|
|
|
|
* conversion if *pivotSource==pivotStart, otherwise from
|
|
|
|
* the pivot-to-target conversion.
|
|
|
|
*
|
|
|
|
* @see ucnv_convert
|
2003-04-21 02:11:54 +00:00
|
|
|
* @see ucnv_fromAlgorithmic
|
|
|
|
* @see ucnv_toAlgorithmic
|
2003-04-18 23:11:39 +00:00
|
|
|
* @see ucnv_fromUnicode
|
|
|
|
* @see ucnv_toUnicode
|
|
|
|
* @see ucnv_fromUChars
|
|
|
|
* @see ucnv_toUChars
|
2004-11-02 07:28:07 +00:00
|
|
|
* @stable ICU 2.6
|
2003-04-18 23:11:39 +00:00
|
|
|
*/
|
2004-11-02 07:28:07 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2003-04-18 23:11:39 +00:00
|
|
|
ucnv_convertEx(UConverter *targetCnv, UConverter *sourceCnv,
|
|
|
|
char **target, const char *targetLimit,
|
|
|
|
const char **source, const char *sourceLimit,
|
|
|
|
UChar *pivotStart, UChar **pivotSource,
|
|
|
|
UChar **pivotTarget, const UChar *pivotLimit,
|
|
|
|
UBool reset, UBool flush,
|
|
|
|
UErrorCode *pErrorCode);
|
|
|
|
|
2001-11-09 18:17:40 +00:00
|
|
|
/**
|
2003-04-21 02:11:54 +00:00
|
|
|
* Convert from one external charset to another.
|
|
|
|
* Internally, two converters are opened according to the name arguments,
|
|
|
|
* then the text is converted to and from the 16-bit Unicode "pivot"
|
|
|
|
* using ucnv_convertEx(), then the converters are closed again.
|
|
|
|
*
|
|
|
|
* This is a convenience function, not an efficient way to convert a lot of text:
|
|
|
|
* ucnv_convert()
|
|
|
|
* - takes charset names, not converter objects, so that
|
|
|
|
* - two converters are opened for each call
|
|
|
|
* - only single-string conversion is possible, not streaming operation
|
|
|
|
* - does not provide enough information to find out,
|
|
|
|
* in case of failure, whether the toUnicode or
|
|
|
|
* the fromUnicode conversion failed
|
|
|
|
* - allows NUL-terminated input
|
|
|
|
* (only a single NUL byte, will not work for charsets with multi-byte NULs)
|
|
|
|
* (if sourceLength==-1, see parameters)
|
|
|
|
* - terminate with a NUL on output
|
|
|
|
* (only a single NUL byte, not useful for charsets with multi-byte NULs),
|
|
|
|
* or set U_STRING_NOT_TERMINATED_WARNING if the output exactly fills
|
|
|
|
* the target buffer
|
|
|
|
* - a pivot buffer is provided internally
|
|
|
|
*
|
|
|
|
* The function returns when one of the following is true:
|
|
|
|
* - the entire source text has been converted successfully to the target buffer
|
|
|
|
* and either the target buffer is terminated with a single NUL byte
|
|
|
|
* or the error code is set to U_STRING_NOT_TERMINATED_WARNING
|
|
|
|
* - a target buffer overflow occurred (U_BUFFER_OVERFLOW_ERROR)
|
|
|
|
* and the full output string length is returned ("preflighting")
|
|
|
|
* - a conversion error occurred
|
|
|
|
* (other U_FAILURE(), see description of pErrorCode)
|
|
|
|
*
|
|
|
|
* @param toConverterName The name of the converter that is used to convert
|
|
|
|
* from the UTF-16 pivot buffer to the target.
|
|
|
|
* @param fromConverterName The name of the converter that is used to convert
|
|
|
|
* from the source to the UTF-16 pivot buffer.
|
|
|
|
* @param target Pointer to the output buffer.
|
|
|
|
* @param targetCapacity Capacity of the target, in bytes.
|
|
|
|
* @param source Pointer to the input buffer.
|
|
|
|
* @param sourceLength Length of the input text, in bytes, or -1 for NUL-terminated input.
|
|
|
|
* @param pErrorCode ICU error code in/out parameter.
|
|
|
|
* Must fulfill U_SUCCESS before the function call.
|
|
|
|
* @return Length of the complete output text in bytes, even if it exceeds the targetCapacity
|
|
|
|
* and a U_BUFFER_OVERFLOW_ERROR is set.
|
2003-04-18 23:11:39 +00:00
|
|
|
*
|
|
|
|
* @see ucnv_convertEx
|
2003-04-21 02:11:54 +00:00
|
|
|
* @see ucnv_fromAlgorithmic
|
|
|
|
* @see ucnv_toAlgorithmic
|
2001-11-09 18:17:40 +00:00
|
|
|
* @see ucnv_fromUnicode
|
|
|
|
* @see ucnv_toUnicode
|
|
|
|
* @see ucnv_fromUChars
|
|
|
|
* @see ucnv_toUChars
|
|
|
|
* @see ucnv_getNextUChar
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2001-11-09 18:17:40 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_convert(const char *toConverterName,
|
|
|
|
const char *fromConverterName,
|
|
|
|
char *target,
|
|
|
|
int32_t targetCapacity,
|
|
|
|
const char *source,
|
|
|
|
int32_t sourceLength,
|
2003-04-21 02:11:54 +00:00
|
|
|
UErrorCode *pErrorCode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert from one external charset to another.
|
|
|
|
* Internally, the text is converted to and from the 16-bit Unicode "pivot"
|
|
|
|
* using ucnv_convertEx(). ucnv_toAlgorithmic() works exactly like ucnv_convert()
|
|
|
|
* except that the two converters need not be looked up and opened completely.
|
|
|
|
*
|
|
|
|
* The source-to-pivot conversion uses the cnv converter parameter.
|
|
|
|
* The pivot-to-target conversion uses a purely algorithmic converter
|
|
|
|
* according to the specified type, e.g., UCNV_UTF8 for a UTF-8 converter.
|
|
|
|
*
|
|
|
|
* Internally, the algorithmic converter is opened and closed for each
|
|
|
|
* function call, which is more efficient than using the public ucnv_open()
|
|
|
|
* but somewhat less efficient than only resetting an existing converter
|
|
|
|
* and using ucnv_convertEx().
|
|
|
|
*
|
|
|
|
* This function is more convenient than ucnv_convertEx() for single-string
|
|
|
|
* conversions, especially when "preflighting" is desired (returning the length
|
|
|
|
* of the complete output even if it does not fit into the target buffer;
|
|
|
|
* see the User Guide Strings chapter). See ucnv_convert() for details.
|
|
|
|
*
|
|
|
|
* @param algorithmicType UConverterType constant identifying the desired target
|
|
|
|
* charset as a purely algorithmic converter.
|
|
|
|
* Those are converters for Unicode charsets like
|
|
|
|
* UTF-8, BOCU-1, SCSU, UTF-7, IMAP-mailbox-name, etc.,
|
|
|
|
* as well as US-ASCII and ISO-8859-1.
|
|
|
|
* @param cnv The converter that is used to convert
|
|
|
|
* from the source to the UTF-16 pivot buffer.
|
|
|
|
* @param target Pointer to the output buffer.
|
|
|
|
* @param targetCapacity Capacity of the target, in bytes.
|
|
|
|
* @param source Pointer to the input buffer.
|
|
|
|
* @param sourceLength Length of the input text, in bytes
|
|
|
|
* @param pErrorCode ICU error code in/out parameter.
|
|
|
|
* Must fulfill U_SUCCESS before the function call.
|
|
|
|
* @return Length of the complete output text in bytes, even if it exceeds the targetCapacity
|
|
|
|
* and a U_BUFFER_OVERFLOW_ERROR is set.
|
|
|
|
*
|
|
|
|
* @see ucnv_fromAlgorithmic
|
|
|
|
* @see ucnv_convert
|
|
|
|
* @see ucnv_convertEx
|
|
|
|
* @see ucnv_fromUnicode
|
|
|
|
* @see ucnv_toUnicode
|
|
|
|
* @see ucnv_fromUChars
|
|
|
|
* @see ucnv_toUChars
|
2004-11-02 07:28:07 +00:00
|
|
|
* @stable ICU 2.6
|
2003-04-21 02:11:54 +00:00
|
|
|
*/
|
2004-11-02 07:28:07 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2003-04-21 02:11:54 +00:00
|
|
|
ucnv_toAlgorithmic(UConverterType algorithmicType,
|
|
|
|
UConverter *cnv,
|
|
|
|
char *target, int32_t targetCapacity,
|
|
|
|
const char *source, int32_t sourceLength,
|
|
|
|
UErrorCode *pErrorCode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert from one external charset to another.
|
|
|
|
* Internally, the text is converted to and from the 16-bit Unicode "pivot"
|
|
|
|
* using ucnv_convertEx(). ucnv_fromAlgorithmic() works exactly like ucnv_convert()
|
|
|
|
* except that the two converters need not be looked up and opened completely.
|
|
|
|
*
|
|
|
|
* The source-to-pivot conversion uses a purely algorithmic converter
|
|
|
|
* according to the specified type, e.g., UCNV_UTF8 for a UTF-8 converter.
|
|
|
|
* The pivot-to-target conversion uses the cnv converter parameter.
|
|
|
|
*
|
|
|
|
* Internally, the algorithmic converter is opened and closed for each
|
|
|
|
* function call, which is more efficient than using the public ucnv_open()
|
|
|
|
* but somewhat less efficient than only resetting an existing converter
|
|
|
|
* and using ucnv_convertEx().
|
|
|
|
*
|
|
|
|
* This function is more convenient than ucnv_convertEx() for single-string
|
|
|
|
* conversions, especially when "preflighting" is desired (returning the length
|
|
|
|
* of the complete output even if it does not fit into the target buffer;
|
|
|
|
* see the User Guide Strings chapter). See ucnv_convert() for details.
|
|
|
|
*
|
|
|
|
* @param cnv The converter that is used to convert
|
|
|
|
* from the UTF-16 pivot buffer to the target.
|
|
|
|
* @param algorithmicType UConverterType constant identifying the desired source
|
|
|
|
* charset as a purely algorithmic converter.
|
|
|
|
* Those are converters for Unicode charsets like
|
|
|
|
* UTF-8, BOCU-1, SCSU, UTF-7, IMAP-mailbox-name, etc.,
|
|
|
|
* as well as US-ASCII and ISO-8859-1.
|
|
|
|
* @param target Pointer to the output buffer.
|
|
|
|
* @param targetCapacity Capacity of the target, in bytes.
|
|
|
|
* @param source Pointer to the input buffer.
|
|
|
|
* @param sourceLength Length of the input text, in bytes
|
|
|
|
* @param pErrorCode ICU error code in/out parameter.
|
|
|
|
* Must fulfill U_SUCCESS before the function call.
|
|
|
|
* @return Length of the complete output text in bytes, even if it exceeds the targetCapacity
|
|
|
|
* and a U_BUFFER_OVERFLOW_ERROR is set.
|
|
|
|
*
|
|
|
|
* @see ucnv_fromAlgorithmic
|
|
|
|
* @see ucnv_convert
|
|
|
|
* @see ucnv_convertEx
|
|
|
|
* @see ucnv_fromUnicode
|
|
|
|
* @see ucnv_toUnicode
|
|
|
|
* @see ucnv_fromUChars
|
|
|
|
* @see ucnv_toUChars
|
2004-11-02 07:28:07 +00:00
|
|
|
* @stable ICU 2.6
|
2003-04-21 02:11:54 +00:00
|
|
|
*/
|
2004-11-02 07:28:07 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2003-04-21 02:11:54 +00:00
|
|
|
ucnv_fromAlgorithmic(UConverter *cnv,
|
|
|
|
UConverterType algorithmicType,
|
|
|
|
char *target, int32_t targetCapacity,
|
|
|
|
const char *source, int32_t sourceLength,
|
|
|
|
UErrorCode *pErrorCode);
|
2000-12-08 21:36:47 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Frees up memory occupied by unused, cached converter shared data.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
|
|
|
* @return the number of cached converters successfully deleted
|
2000-12-08 21:36:47 +00:00
|
|
|
* @see ucnv_close
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_flushCache(void);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2003-01-29 01:17:11 +00:00
|
|
|
* Returns the number of available converters, as per the alias file.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
|
|
|
* @return the number of available converters
|
|
|
|
* @see ucnv_getAvailableName
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_countAvailable(void);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-12-08 21:36:47 +00:00
|
|
|
/**
|
2003-01-29 01:17:11 +00:00
|
|
|
* Gets the canonical converter name of the specified converter from a list of
|
|
|
|
* all available converters contaied in the alias file. All converters
|
|
|
|
* in this list can be opened.
|
|
|
|
*
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param n the index to a converter available on the system (in the range <TT>[0..ucnv_countAvaiable()]</TT>)
|
|
|
|
* @return a pointer a string (library owned), or <TT>NULL</TT> if the index is out of bounds.
|
|
|
|
* @see ucnv_countAvailable
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-12-08 21:36:47 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE const char* U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getAvailableName(int32_t n);
|
2000-01-14 23:29:01 +00:00
|
|
|
|
2002-10-30 22:52:08 +00:00
|
|
|
/**
|
|
|
|
* Returns a UEnumeration to enumerate all of the canonical converter
|
|
|
|
* names, as per the alias file, regardless of the ability to open each
|
|
|
|
* converter.
|
|
|
|
*
|
|
|
|
* @return A UEnumeration object for getting all the recognized canonical
|
|
|
|
* converter names.
|
|
|
|
* @see ucnv_getAvailableName
|
|
|
|
* @see uenum_close
|
|
|
|
* @see uenum_next
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-10-30 22:52:08 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE UEnumeration * U_EXPORT2
|
2002-10-30 22:52:08 +00:00
|
|
|
ucnv_openAllNames(UErrorCode *pErrorCode);
|
|
|
|
|
2000-01-14 23:29:01 +00:00
|
|
|
/**
|
2000-12-08 21:36:47 +00:00
|
|
|
* Gives the number of aliases for a given converter or alias name.
|
2002-08-08 22:46:05 +00:00
|
|
|
* If the alias is ambiguous, then the preferred converter is used
|
|
|
|
* and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
|
2000-07-19 22:18:43 +00:00
|
|
|
* This method only enumerates the listed entries in the alias file.
|
2000-01-14 23:29:01 +00:00
|
|
|
* @param alias alias name
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param pErrorCode error status
|
|
|
|
* @return number of names on alias list for given alias
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-01-14 23:29:01 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE uint16_t U_EXPORT2
|
2000-01-14 23:29:01 +00:00
|
|
|
ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);
|
|
|
|
|
|
|
|
/**
|
2000-07-19 22:18:43 +00:00
|
|
|
* Gives the name of the alias at given index of alias list.
|
|
|
|
* This method only enumerates the listed entries in the alias file.
|
2002-08-08 22:46:05 +00:00
|
|
|
* If the alias is ambiguous, then the preferred converter is used
|
|
|
|
* and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
|
2000-01-14 23:29:01 +00:00
|
|
|
* @param alias alias name
|
2000-04-14 05:22:29 +00:00
|
|
|
* @param n index in alias list
|
2000-01-14 23:29:01 +00:00
|
|
|
* @param pErrorCode result of operation
|
|
|
|
* @return returns the name of the alias at given index
|
2000-12-08 21:36:47 +00:00
|
|
|
* @see ucnv_countAliases
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-01-14 23:29:01 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE const char * U_EXPORT2
|
2000-04-14 05:22:29 +00:00
|
|
|
ucnv_getAlias(const char *alias, uint16_t n, UErrorCode *pErrorCode);
|
2000-01-14 23:29:01 +00:00
|
|
|
|
|
|
|
/**
|
2000-07-19 22:18:43 +00:00
|
|
|
* Fill-up the list of alias names for the given alias.
|
|
|
|
* This method only enumerates the listed entries in the alias file.
|
2002-08-08 22:46:05 +00:00
|
|
|
* If the alias is ambiguous, then the preferred converter is used
|
|
|
|
* and the status is set to U_AMBIGUOUS_ALIAS_WARNING.
|
2000-01-14 23:29:01 +00:00
|
|
|
* @param alias alias name
|
2000-01-20 00:33:18 +00:00
|
|
|
* @param aliases fill-in list, aliases is a pointer to an array of
|
|
|
|
* <code>ucnv_countAliases()</code> string-pointers
|
2000-12-08 21:36:47 +00:00
|
|
|
* (<code>const char *</code>) that will be filled in.
|
|
|
|
* The strings themselves are owned by the library.
|
2000-01-14 23:29:01 +00:00
|
|
|
* @param pErrorCode result of operation
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-01-14 23:29:01 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2000-01-14 23:29:01 +00:00
|
|
|
ucnv_getAliases(const char *alias, const char **aliases, UErrorCode *pErrorCode);
|
|
|
|
|
2002-07-13 16:32:16 +00:00
|
|
|
/**
|
|
|
|
* Return a new UEnumeration object for enumerating all the
|
|
|
|
* alias names for a given converter that are recognized by a standard.
|
|
|
|
* This method only enumerates the listed entries in the alias file.
|
|
|
|
* The convrtrs.txt file can be modified to change the results of
|
|
|
|
* this function.
|
|
|
|
* The first result in this list is the same result given by
|
|
|
|
* <code>ucnv_getStandardName</code>, which is the default alias for
|
|
|
|
* the specified standard name. The returned object must be closed with
|
|
|
|
* <code>uenum_close</code> when you are done with the object.
|
|
|
|
*
|
|
|
|
* @param convName original converter name
|
|
|
|
* @param standard name of the standard governing the names; MIME and IANA
|
|
|
|
* are such standards
|
|
|
|
* @param pErrorCode The error code
|
|
|
|
* @return A UEnumeration object for getting all aliases that are recognized
|
|
|
|
* by a standard. If any of the parameters are invalid, NULL
|
|
|
|
* is returned.
|
|
|
|
* @see ucnv_getStandardName
|
|
|
|
* @see uenum_close
|
|
|
|
* @see uenum_next
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-07-13 16:32:16 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE UEnumeration * U_EXPORT2
|
2002-07-13 16:32:16 +00:00
|
|
|
ucnv_openStandardNames(const char *convName,
|
|
|
|
const char *standard,
|
|
|
|
UErrorCode *pErrorCode);
|
|
|
|
|
2000-06-30 19:43:00 +00:00
|
|
|
/**
|
2000-08-10 01:32:29 +00:00
|
|
|
* Gives the number of standards associated to converter names.
|
|
|
|
* @return number of standards
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-08-10 01:32:29 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE uint16_t U_EXPORT2
|
2000-11-17 19:28:31 +00:00
|
|
|
ucnv_countStandards(void);
|
2000-08-10 01:32:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gives the name of the standard at given index of standard list.
|
|
|
|
* @param n index in standard list
|
|
|
|
* @param pErrorCode result of operation
|
2000-12-08 21:36:47 +00:00
|
|
|
* @return returns the name of the standard at given index. Owned by the library.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-08-10 01:32:29 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE const char * U_EXPORT2
|
2000-08-10 01:32:29 +00:00
|
|
|
ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a standard name for a given converter name.
|
2003-01-29 01:17:11 +00:00
|
|
|
* <p>
|
|
|
|
* Example alias table:<br>
|
|
|
|
* conv alias1 { STANDARD1 } alias2 { STANDARD1* }
|
|
|
|
* <p>
|
|
|
|
* Result of ucnv_getStandardName("conv", "STANDARD1") from example
|
|
|
|
* alias table:<br>
|
|
|
|
* <b>"alias2"</b>
|
2000-06-30 19:43:00 +00:00
|
|
|
*
|
|
|
|
* @param name original converter name
|
|
|
|
* @param standard name of the standard governing the names; MIME and IANA
|
|
|
|
* are such standards
|
2003-04-25 23:47:18 +00:00
|
|
|
* @param pErrorCode result of operation
|
2000-06-30 19:43:00 +00:00
|
|
|
* @return returns the standard converter name;
|
|
|
|
* if a standard converter name cannot be determined,
|
2000-12-08 21:36:47 +00:00
|
|
|
* then <code>NULL</code> is returned. Owned by the library.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-06-30 19:43:00 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE const char * U_EXPORT2
|
2000-11-17 02:02:11 +00:00
|
|
|
ucnv_getStandardName(const char *name, const char *standard, UErrorCode *pErrorCode);
|
2000-06-30 19:43:00 +00:00
|
|
|
|
2002-10-30 22:52:08 +00:00
|
|
|
/**
|
|
|
|
* This function will return the internal canonical converter name of the
|
|
|
|
* tagged alias. This is the opposite of ucnv_openStandardNames, which
|
|
|
|
* returns the tagged alias given the canonical name.
|
2003-01-29 01:17:11 +00:00
|
|
|
* <p>
|
|
|
|
* Example alias table:<br>
|
|
|
|
* conv alias1 { STANDARD1 } alias2 { STANDARD1* }
|
|
|
|
* <p>
|
|
|
|
* Result of ucnv_getStandardName("alias1", "STANDARD1") from example
|
|
|
|
* alias table:<br>
|
|
|
|
* <b>"conv"</b>
|
2002-10-30 22:52:08 +00:00
|
|
|
*
|
|
|
|
* @return returns the canonical converter name;
|
|
|
|
* if a standard or alias name cannot be determined,
|
|
|
|
* then <code>NULL</code> is returned. The returned string is
|
|
|
|
* owned by the library.
|
|
|
|
* @see ucnv_getStandardName
|
2004-03-26 19:42:04 +00:00
|
|
|
* @stable ICU 2.4
|
2002-10-30 22:52:08 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE const char * U_EXPORT2
|
2002-10-30 22:52:08 +00:00
|
|
|
ucnv_getCanonicalName(const char *alias, const char *standard, UErrorCode *pErrorCode);
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2007-06-07 05:15:52 +00:00
|
|
|
* Returns the current default converter name. If you want to open
|
|
|
|
* a default converter, you do not need to use this function.
|
|
|
|
* It is faster if you pass a NULL argument to ucnv_open the
|
|
|
|
* default converter.
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
2009-03-11 03:16:35 +00:00
|
|
|
* If U_CHARSET_IS_UTF8 is defined to 1 in utypes.h then this function
|
|
|
|
* always returns "UTF-8".
|
|
|
|
*
|
2007-06-07 05:15:52 +00:00
|
|
|
* @return returns the current default converter name.
|
2000-12-08 21:36:47 +00:00
|
|
|
* Storage owned by the library
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_setDefaultName
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE const char * U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_getDefaultName(void);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2011-08-01 02:38:58 +00:00
|
|
|
#ifndef U_HIDE_SYSTEM_API
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
2007-06-07 05:15:52 +00:00
|
|
|
* This function is not thread safe. DO NOT call this function when ANY ICU
|
|
|
|
* function is being used from more than one thread! This function sets the
|
|
|
|
* current default converter name. If this function needs to be called, it
|
|
|
|
* should be called during application initialization. Most of the time, the
|
|
|
|
* results from ucnv_getDefaultName() or ucnv_open with a NULL string argument
|
|
|
|
* is sufficient for your application.
|
2009-03-11 03:16:35 +00:00
|
|
|
*
|
|
|
|
* If U_CHARSET_IS_UTF8 is defined to 1 in utypes.h then this function
|
|
|
|
* does nothing.
|
|
|
|
*
|
2007-06-07 05:15:52 +00:00
|
|
|
* @param name the converter name to be the default (must be known by ICU).
|
1999-12-28 23:39:02 +00:00
|
|
|
* @see ucnv_getDefaultName
|
2006-06-12 22:48:41 +00:00
|
|
|
* @system
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2006-06-12 22:48:41 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_setDefaultName(const char *name);
|
2011-08-01 02:38:58 +00:00
|
|
|
#endif /* U_HIDE_SYSTEM_API */
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-01-08 00:51:44 +00:00
|
|
|
/**
|
|
|
|
* Fixes the backslash character mismapping. For example, in SJIS, the backslash
|
|
|
|
* character in the ASCII portion is also used to represent the yen currency sign.
|
|
|
|
* When mapping from Unicode character 0x005C, it's unclear whether to map the
|
|
|
|
* character back to yen or backslash in SJIS. This function will take the input
|
|
|
|
* buffer and replace all the yen sign characters with backslash. This is necessary
|
|
|
|
* when the user tries to open a file with the input buffer on Windows.
|
2000-12-08 21:36:47 +00:00
|
|
|
* This function will test the converter to see whether such mapping is
|
2001-11-09 18:17:40 +00:00
|
|
|
* required. You can sometimes avoid using this function by using the correct version
|
|
|
|
* of Shift-JIS.
|
|
|
|
*
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param cnv The converter representing the target codepage.
|
2000-01-08 00:51:44 +00:00
|
|
|
* @param source the input buffer to be fixed
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param sourceLen the length of the input buffer
|
2000-12-08 21:36:47 +00:00
|
|
|
* @see ucnv_isAmbiguous
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-01-08 00:51:44 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_fixFileSeparator(const UConverter *cnv, UChar *source, int32_t sourceLen);
|
2000-01-08 00:51:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if the converter contains ambiguous mappings of the same
|
|
|
|
* character or not.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param cnv the converter to be tested
|
2000-01-08 00:51:44 +00:00
|
|
|
* @return TRUE if the converter contains ambiguous mapping of the same
|
|
|
|
* character, FALSE otherwise.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-01-08 00:51:44 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE UBool U_EXPORT2
|
2000-12-08 21:36:47 +00:00
|
|
|
ucnv_isAmbiguous(const UConverter *cnv);
|
2000-01-08 00:51:44 +00:00
|
|
|
|
2000-05-12 19:59:03 +00:00
|
|
|
/**
|
2007-08-24 19:49:03 +00:00
|
|
|
* Sets the converter to use fallback mappings or not.
|
|
|
|
* Regardless of this flag, the converter will always use
|
|
|
|
* fallbacks from Unicode Private Use code points, as well as
|
|
|
|
* reverse fallbacks (to Unicode).
|
|
|
|
* For details see ".ucm File Format"
|
|
|
|
* in the Conversion Data chapter of the ICU User Guide:
|
|
|
|
* http://www.icu-project.org/userguide/conversion-data.html#ucmformat
|
|
|
|
*
|
2000-12-08 21:36:47 +00:00
|
|
|
* @param cnv The converter to set the fallback mapping usage on.
|
2000-05-12 19:59:03 +00:00
|
|
|
* @param usesFallback TRUE if the user wants the converter to take advantage of the fallback
|
|
|
|
* mapping, FALSE otherwise.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2007-08-24 19:49:03 +00:00
|
|
|
* @see ucnv_usesFallback
|
2000-05-12 19:59:03 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2002-01-08 01:05:57 +00:00
|
|
|
ucnv_setFallback(UConverter *cnv, UBool usesFallback);
|
2000-05-12 19:59:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if the converter uses fallback mappings or not.
|
2007-08-24 19:49:03 +00:00
|
|
|
* This flag has restrictions, see ucnv_setFallback().
|
|
|
|
*
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param cnv The converter to be tested
|
2000-05-12 19:59:03 +00:00
|
|
|
* @return TRUE if the converter uses fallback, FALSE otherwise.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2007-08-24 19:49:03 +00:00
|
|
|
* @see ucnv_setFallback
|
2000-05-12 19:59:03 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE UBool U_EXPORT2
|
2002-01-08 01:05:57 +00:00
|
|
|
ucnv_usesFallback(const UConverter *cnv);
|
|
|
|
|
|
|
|
/**
|
2002-11-08 01:28:14 +00:00
|
|
|
* Detects Unicode signature byte sequences at the start of the byte stream
|
|
|
|
* and returns the charset name of the indicated Unicode charset.
|
|
|
|
* NULL is returned when no Unicode signature is recognized.
|
|
|
|
* The number of bytes in the signature is output as well.
|
|
|
|
*
|
|
|
|
* The caller can ucnv_open() a converter using the charset name.
|
|
|
|
* The first code unit (UChar) from the start of the stream will be U+FEFF
|
|
|
|
* (the Unicode BOM/signature character) and can usually be ignored.
|
|
|
|
*
|
|
|
|
* For most Unicode charsets it is also possible to ignore the indicated
|
|
|
|
* number of initial stream bytes and start converting after them.
|
|
|
|
* However, there are stateful Unicode charsets (UTF-7 and BOCU-1) for which
|
|
|
|
* this will not work. Therefore, it is best to ignore the first output UChar
|
|
|
|
* instead of the input signature bytes.
|
2002-01-08 01:05:57 +00:00
|
|
|
* <p>
|
|
|
|
* Usage:
|
|
|
|
* @code
|
|
|
|
* UErrorCode err = U_ZERO_ERROR;
|
|
|
|
* char input[] = { '\xEF','\xBB', '\xBF','\x41','\x42','\x43' };
|
|
|
|
* int32_t signatureLength = 0;
|
2006-07-05 23:08:50 +00:00
|
|
|
* char *encoding = ucnv_detectUnicodeSignature(input,sizeof(input),&signatureLength,&err);
|
2002-11-08 01:28:14 +00:00
|
|
|
* UConverter *conv = NULL;
|
|
|
|
* UChar output[100];
|
|
|
|
* UChar *target = output, *out;
|
|
|
|
* char *source = input;
|
2002-01-08 01:05:57 +00:00
|
|
|
* if(encoding!=NULL && U_SUCCESS(err)){
|
|
|
|
* // should signature be discarded ?
|
2002-11-08 01:28:14 +00:00
|
|
|
* conv = ucnv_open(encoding, &err);
|
|
|
|
* // do the conversion
|
|
|
|
* ucnv_toUnicode(conv,
|
|
|
|
* target, output + sizeof(output)/U_SIZEOF_UCHAR,
|
|
|
|
* source, input + sizeof(input),
|
|
|
|
* NULL, TRUE, &err);
|
|
|
|
* out = output;
|
2002-01-08 01:05:57 +00:00
|
|
|
* if (discardSignature){
|
2002-11-08 01:28:14 +00:00
|
|
|
* ++out; // ignore initial U+FEFF
|
2002-01-08 01:05:57 +00:00
|
|
|
* }
|
2002-11-08 01:28:14 +00:00
|
|
|
* while(out != target) {
|
|
|
|
* printf("%04x ", *out++);
|
|
|
|
* }
|
|
|
|
* puts("");
|
2002-01-08 01:05:57 +00:00
|
|
|
* }
|
|
|
|
*
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* @param source The source string in which the signature should be detected.
|
2002-11-08 01:28:14 +00:00
|
|
|
* @param sourceLength Length of the input string, or -1 if terminated with a NUL byte.
|
|
|
|
* @param signatureLength A pointer to int32_t to receive the number of bytes that make up the signature
|
2002-01-08 01:05:57 +00:00
|
|
|
* of the detected UTF. 0 if not detected.
|
2002-11-08 01:28:14 +00:00
|
|
|
* Can be a NULL pointer.
|
2005-02-01 01:06:48 +00:00
|
|
|
* @param pErrorCode ICU error code in/out parameter.
|
|
|
|
* Must fulfill U_SUCCESS before the function call.
|
2002-01-08 01:05:57 +00:00
|
|
|
* @return The name of the encoding detected. NULL if encoding is not detected.
|
2002-12-12 00:27:50 +00:00
|
|
|
* @stable ICU 2.4
|
2002-01-08 01:05:57 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE const char* U_EXPORT2
|
2003-01-29 01:17:11 +00:00
|
|
|
ucnv_detectUnicodeSignature(const char* source,
|
|
|
|
int32_t sourceLength,
|
|
|
|
int32_t *signatureLength,
|
|
|
|
UErrorCode *pErrorCode);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2005-01-28 02:45:30 +00:00
|
|
|
/**
|
2005-02-01 01:06:48 +00:00
|
|
|
* Returns the number of UChars held in the converter's internal state
|
|
|
|
* because more input is needed for completing the conversion. This function is
|
|
|
|
* useful for mapping semantics of ICU's converter interface to those of iconv,
|
|
|
|
* and this information is not needed for normal conversion.
|
2005-01-28 02:45:30 +00:00
|
|
|
* @param cnv The converter in which the input is held
|
2005-02-01 01:06:48 +00:00
|
|
|
* @param status ICU error code in/out parameter.
|
|
|
|
* Must fulfill U_SUCCESS before the function call.
|
|
|
|
* @return The number of UChars in the state. -1 if an error is encountered.
|
2007-08-19 08:59:28 +00:00
|
|
|
* @stable ICU 3.4
|
2005-01-28 02:45:30 +00:00
|
|
|
*/
|
2007-08-19 08:59:28 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2005-02-01 01:06:48 +00:00
|
|
|
ucnv_fromUCountPending(const UConverter* cnv, UErrorCode* status);
|
2005-01-28 02:45:30 +00:00
|
|
|
|
|
|
|
/**
|
2005-02-01 01:06:48 +00:00
|
|
|
* Returns the number of chars held in the converter's internal state
|
|
|
|
* because more input is needed for completing the conversion. This function is
|
|
|
|
* useful for mapping semantics of ICU's converter interface to those of iconv,
|
|
|
|
* and this information is not needed for normal conversion.
|
2005-01-28 02:45:30 +00:00
|
|
|
* @param cnv The converter in which the input is held as internal state
|
2005-02-01 01:06:48 +00:00
|
|
|
* @param status ICU error code in/out parameter.
|
|
|
|
* Must fulfill U_SUCCESS before the function call.
|
|
|
|
* @return The number of chars in the state. -1 if an error is encountered.
|
2007-08-19 08:59:28 +00:00
|
|
|
* @stable ICU 3.4
|
2005-01-28 02:45:30 +00:00
|
|
|
*/
|
2007-08-19 08:59:28 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2005-02-01 01:06:48 +00:00
|
|
|
ucnv_toUCountPending(const UConverter* cnv, UErrorCode* status);
|
2005-01-28 02:45:30 +00:00
|
|
|
|
2011-08-01 02:20:46 +00:00
|
|
|
#ifndef U_HIDE_DRAFT_API
|
2011-02-23 22:21:58 +00:00
|
|
|
/**
|
2011-03-29 04:20:18 +00:00
|
|
|
* Returns whether or not the charset of the converter has a fixed number of bytes
|
|
|
|
* per charset character.
|
|
|
|
* An example of this are converters that are of the type UCNV_SBCS or UCNV_DBCS.
|
2011-05-07 01:09:01 +00:00
|
|
|
* Another example is UTF-32 which is always 4 bytes per character.
|
|
|
|
* A Unicode code point may be represented by more than one UTF-8 or UTF-16 code unit
|
|
|
|
* but a UTF-32 converter encodes each code point with 4 bytes.
|
2011-03-29 04:20:18 +00:00
|
|
|
* Note: This method is not intended to be used to determine whether the charset has a
|
2011-05-07 01:09:01 +00:00
|
|
|
* fixed ratio of bytes to Unicode codes <i>units</i> for any particular Unicode encoding form.
|
2011-02-23 22:21:58 +00:00
|
|
|
* FALSE is returned with the UErrorCode if error occurs or cnv is NULL.
|
|
|
|
* @param cnv The converter to be tested
|
|
|
|
* @param status ICU error code in/out paramter
|
|
|
|
* @return TRUE if the converter is fixed-width
|
|
|
|
* @draft ICU 4.8
|
|
|
|
*/
|
|
|
|
U_DRAFT UBool U_EXPORT2
|
|
|
|
ucnv_isFixedWidth(UConverter *cnv, UErrorCode *status);
|
2011-08-01 02:20:46 +00:00
|
|
|
#endif /* U_HIDE_DRAFT_API */
|
2011-02-23 22:21:58 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
#endif
|
2000-05-12 19:59:03 +00:00
|
|
|
|
2004-08-26 22:51:40 +00:00
|
|
|
#endif
|
|
|
|
/*_UCNV*/
|