2001-03-21 20:44:20 +00:00
|
|
|
/*****************************************************************************
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
2001-03-21 20:44:20 +00:00
|
|
|
* Copyright (C) 1998-2001, International Business Machines
|
1999-12-28 23:39:02 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
2000-06-27 20:47:56 +00:00
|
|
|
*
|
|
|
|
* Change history:
|
|
|
|
*
|
|
|
|
* 06/29/2000 helena Major rewrite of the callback APIs.
|
2001-03-21 20:44:20 +00:00
|
|
|
*****************************************************************************/
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
#ifndef CONVERT_H
|
|
|
|
#define CONVERT_H
|
|
|
|
|
2002-06-27 01:19:20 +00:00
|
|
|
#include "unicode/utypes.h"
|
2002-08-21 19:12:24 +00:00
|
|
|
|
|
|
|
#ifdef ICU_UNICODECONVERTER_USE_DEPRECATES
|
2002-06-27 01:19:20 +00:00
|
|
|
#include "unicode/uobject.h"
|
1999-12-28 23:39:02 +00:00
|
|
|
#include "unicode/unistr.h"
|
|
|
|
#include "unicode/ucnv.h"
|
2001-09-19 00:14:07 +00:00
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
2000-12-08 18:43:57 +00:00
|
|
|
/**
|
2002-12-06 00:19:24 +00:00
|
|
|
* This class is obsolete and will be removed.
|
2001-09-19 00:14:07 +00:00
|
|
|
* Use the more powerful C conversion API with the UConverter type and ucnv_... functions.
|
|
|
|
*
|
|
|
|
* There are also two new functions in ICU 2.0 that convert a UnicodeString
|
|
|
|
* and extract a UnicodeString using a UConverter (search unistr.h for UConverter).
|
|
|
|
* They replace the fromUnicodeString() and toUnicodeString() functions here.
|
|
|
|
* All other UnicodeConverter functions are basically aliases of C API functions.
|
|
|
|
*
|
|
|
|
* Old documentation:
|
|
|
|
*
|
2000-12-08 18:43:57 +00:00
|
|
|
* UnicodeConverter is a C++ wrapper class for UConverter.
|
|
|
|
* You need one UnicodeConverter object in place of one UConverter object.
|
|
|
|
* For details on the API and implementation of the
|
2001-09-19 00:14:07 +00:00
|
|
|
* codepage converter interface see ucnv.h.
|
2000-12-08 18:43:57 +00:00
|
|
|
*
|
|
|
|
* @see UConverter
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the C API with UConverter and ucnv_... functions instead since this API will be removed in that release.
|
2000-12-08 18:43:57 +00:00
|
|
|
*/
|
2002-06-27 01:19:20 +00:00
|
|
|
class U_COMMON_API UnicodeConverter : public UObject {
|
1999-12-28 23:39:02 +00:00
|
|
|
private:
|
|
|
|
/*Internal Data representation of the Converter*/
|
|
|
|
UConverter* myUnicodeConverter;
|
|
|
|
/*Debug method*/
|
|
|
|
void printRef(void) const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
//Constructors and a destructor
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates Unicode Conversion Object will default to LATIN1 <-> encoding
|
2001-12-03 21:58:00 +00:00
|
|
|
* @return the created Unicode converter object
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-08-01 00:44:15 +00:00
|
|
|
UnicodeConverter();
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates Unicode Conversion Object by specifying the codepage name. The name
|
|
|
|
* string is in ASCII format.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param name the pointer to a char[] object containing a codepage name. (I)
|
|
|
|
* @param err Error status (I/O) IILLEGAL_ARGUMENT_ERROR will be returned if the string is empty.
|
1999-12-28 23:39:02 +00:00
|
|
|
* If the internal program does not work correctly, for example, if there's no such codepage,
|
|
|
|
* U_INTERNAL_PROGRAM_ERROR will be returned.
|
2001-12-03 21:58:00 +00:00
|
|
|
* @return the created Unicode converter object
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-08-01 00:44:15 +00:00
|
|
|
UnicodeConverter(const char* name,
|
1999-12-28 23:39:02 +00:00
|
|
|
UErrorCode& err);
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Creates a UnicodeConverter object with the names specified as unicode strings. The name should be limited to
|
|
|
|
*the ASCII-7 alphanumerics. Dash and underscore characters are allowed for readability, but are ignored in the
|
|
|
|
*search.
|
2002-07-03 12:05:56 +00:00
|
|
|
*@param name name of the uconv table in Unicode string (I)
|
1999-12-28 23:39:02 +00:00
|
|
|
*@param err error status (I/O) IILLEGAL_ARGUMENT_ERROR will be returned if the string is empty. If the internal
|
|
|
|
*program does not work correctly, for example, if there's no such codepage, U_INTERNAL_PROGRAM_ERROR will be
|
|
|
|
*returned.
|
|
|
|
*@return the created Unicode converter object
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-08-01 00:44:15 +00:00
|
|
|
UnicodeConverter(const UnicodeString& name,
|
1999-12-28 23:39:02 +00:00
|
|
|
UErrorCode& err);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates Unicode Conversion Object using the codepage ID number.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param codepageNumber a codepage # (I)
|
|
|
|
* @param platform Enum for specifying which platform a converter ID refers to.
|
|
|
|
* @UErrorCode err Error status (I/O) IILLEGAL_ARGUMENT_ERROR will be returned if the string is empty.
|
1999-12-28 23:39:02 +00:00
|
|
|
* If the internal program does not work correctly, for example, if there's no such codepage,
|
|
|
|
* U_INTERNAL_PROGRAM_ERROR will be returned.
|
2001-12-03 21:58:00 +00:00
|
|
|
* @return the Unicode converter object
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-08-01 00:44:15 +00:00
|
|
|
UnicodeConverter(int32_t codepageNumber,
|
1999-12-28 23:39:02 +00:00
|
|
|
UConverterPlatform platform,
|
|
|
|
UErrorCode& err);
|
|
|
|
|
2000-08-01 00:44:15 +00:00
|
|
|
~UnicodeConverter();
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transcodes the source UnicodeString to the target string in a codepage encoding
|
|
|
|
* with the specified Unicode converter. For example, if a Unicode to/from JIS
|
|
|
|
* converter is specified, the source string in Unicode will be transcoded to JIS
|
|
|
|
* encoding. The result will be stored in JIS encoding.
|
|
|
|
*
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param target The target string in codepage encoding
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param targetSize Input the number of bytes available in the "target" buffer, Output the number of bytes copied to it
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param source the source Unicode string
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param err the error status code. U_MEMORY_ALLOCATION_ERROR will be returned if the
|
|
|
|
* the internal process buffer cannot be allocated for transcoding. U_ILLEGAL_ARGUMENT_ERROR
|
|
|
|
* is returned if the converter is null or the source or target string is empty.
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
void fromUnicodeString(char* target,
|
|
|
|
int32_t& targetSize,
|
|
|
|
const UnicodeString& source,
|
|
|
|
UErrorCode& err) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transcode the source string in codepage encoding to the target string in
|
|
|
|
* Unicode encoding. For example, if a Unicode to/from JIS
|
|
|
|
* converter is specified, the source string in JIS encoding will be transcoded
|
|
|
|
* to Unicode encoding. The result will be stored in Unicode encoding.
|
|
|
|
* @param target the target string in Unicode encoding
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param source the source string in codepage encoding
|
|
|
|
* @param sourceSize : I/O parameter, Input size buffer, Output # of bytes copied to it
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param err the error status code U_MEMORY_ALLOCATION_ERROR will be returned if the
|
|
|
|
* the internal process buffer cannot be allocated for transcoding. U_ILLEGAL_ARGUMENT_ERROR
|
|
|
|
* is returned if the converter is null or the source or target string is empty.
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
void toUnicodeString(UnicodeString& target,
|
|
|
|
const char* source,
|
|
|
|
int32_t sourceSize,
|
|
|
|
UErrorCode& err) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transcodes an array of unicode characters to an array of codepage characters.
|
|
|
|
* The source pointer is an I/O parameter, it starts out pointing at the place
|
|
|
|
* to begin translating, and ends up pointing after the first sequence of the bytes
|
|
|
|
* that it encounters that are semantically invalid.
|
|
|
|
* if T_UnicodeConverter_setMissingCharAction is called with an action other than STOP
|
|
|
|
* before a call is made to this API, consumed and source should point to the same place
|
|
|
|
* (unless target ends with an imcomplete sequence of bytes and flush is FALSE).
|
|
|
|
* @param target : I/O parameter. Input : Points to the beginning of the buffer to copy
|
|
|
|
* codepage characters to. Output : points to after the last codepage character copied
|
|
|
|
* to target.
|
|
|
|
* @param targetLimit the pointer to the end of the target array
|
|
|
|
* @param source the source Unicode character array
|
|
|
|
* @param sourceLimit the pointer to the end of the source array
|
2001-12-03 21:58:00 +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>
|
|
|
|
* 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,
|
|
|
|
* this function may have to be called multiple times wiht flush set to <TT>TRUE</TT> until
|
|
|
|
* the source buffer is consumed.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param flush TRUE if the buffer is the last buffer and the conversion will finish
|
|
|
|
* in this call, FALSE otherwise. (future feature pending)
|
|
|
|
* @param UErrorCode the error status. U_ILLEGAL_ARGUMENT_ERROR will be returned if the
|
|
|
|
* converter is null.
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
void fromUnicode(char*& target,
|
|
|
|
const char* targetLimit,
|
|
|
|
const UChar*& source,
|
|
|
|
const UChar* sourceLimit,
|
2000-08-11 21:56:35 +00:00
|
|
|
int32_t * offsets,
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool flush,
|
1999-12-28 23:39:02 +00:00
|
|
|
UErrorCode& err);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts an array of codepage characters into an array of unicode characters.
|
|
|
|
* The source pointer is an I/O parameter, it starts out pointing at the place
|
|
|
|
* to begin translating, and ends up pointing after the first sequence of the bytes
|
|
|
|
* that it encounters that are semantically invalid.
|
|
|
|
* if T_UnicodeConverter_setMissingUnicodeAction is called with an action other than STOP
|
|
|
|
* before a call is made to this API, consumed and source should point to the same place
|
|
|
|
* (unless target ends with an imcomplete sequence of bytes and flush is FALSE).
|
|
|
|
* @param target : I/O parameter. Input : Points to the beginning of the buffer to copy
|
|
|
|
* Unicode characters to. Output : points to after the last UChar copied to target.
|
|
|
|
* @param targetLimit the pointer to the end of the target array
|
|
|
|
* @param source the source codepage character array
|
|
|
|
* @param sourceLimit the pointer to the end of the source array
|
2001-12-03 21:58:00 +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>
|
|
|
|
* 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,
|
|
|
|
* this function may have to be called multiple times wiht flush set to <TT>TRUE</TT> until
|
|
|
|
* the source buffer is consumed.
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param flush TRUE if the buffer is the last buffer and the conversion will finish
|
|
|
|
* in this call, FALSE otherwise. (future feature pending)
|
|
|
|
* @param err the error code status U_ILLEGAL_ARGUMENT_ERROR will be returned if the
|
|
|
|
* converter is null, targetLimit < target, sourceLimit < source
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
void toUnicode(UChar*& target,
|
|
|
|
const UChar* targetLimit,
|
|
|
|
const char*& source,
|
|
|
|
const char* sourceLimit,
|
2000-08-11 21:56:35 +00:00
|
|
|
int32_t * offsets,
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool flush,
|
1999-12-28 23:39:02 +00:00
|
|
|
UErrorCode& err);
|
|
|
|
|
|
|
|
|
2000-03-22 18:31:40 +00:00
|
|
|
/**
|
|
|
|
* Returns the maximum length of bytes used by a character. This varies between 1 and 4
|
|
|
|
* @return the max number of bytes per codepage character * converter is null, targetLimit < target, sourceLimit < source
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
1999-12-28 23:39:02 +00:00
|
|
|
int8_t getMaxBytesPerChar(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the minimum byte length for characters in this codepage. This is either
|
|
|
|
* 1 or 2 for all supported codepages.
|
|
|
|
* @return the minimum number of byte per codepage character
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
int8_t getMinBytesPerChar(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Gets the type of conversion associated with the converter
|
|
|
|
* e.g. SBCS, MBCS, DBCS, UTF8, UTF16_BE, UTF16_LE, ISO_2022, EBCDIC_STATEFUL, LATIN_1
|
|
|
|
* @return the type of the converter
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
UConverterType getType(void) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Gets the "starter" bytes for the 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 boolean, with the value of the byte as offset to the array.
|
|
|
|
*At return, if TRUE is found in at offset 0x20, it means that the byte 0x20 is a starter byte
|
|
|
|
*in this converter.
|
|
|
|
* @param starters: an array of size 256 to be filled in
|
|
|
|
* @param err: an array of size 256 to be filled in
|
|
|
|
* @see ucnv_getType
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
void getStarters(UBool starters[256],
|
2000-08-11 21:56:35 +00:00
|
|
|
UErrorCode& err) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Fills in the output parameter, subChars, with the substitution characters
|
|
|
|
* as multiple bytes.
|
|
|
|
* @param subChars the subsitution characters
|
|
|
|
* @param len the number of bytes of the substitution character array
|
|
|
|
* @param err the error status code. U_ILLEGAL_ARGUMENT_ERROR will be returned if
|
|
|
|
* the converter is null. If the substitution character array is too small, an
|
|
|
|
* U_INDEX_OUTOFBOUNDS_ERROR will be returned.
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
void getSubstitutionChars(char* subChars,
|
|
|
|
int8_t& len,
|
|
|
|
UErrorCode& err) const;
|
|
|
|
/**
|
|
|
|
* Sets the substitution chars when converting from unicode to a codepage. The
|
|
|
|
* substitution is specified as a string of 1-4 bytes, and may contain null byte.
|
|
|
|
* The fill-in parameter err will get the error status on return.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param subchars the substitution character array to be set with
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param len the number of bytes of the substitution character array and upon return will contain the
|
|
|
|
* number of bytes copied to that buffer
|
|
|
|
* @param err the error status code. U_ILLEGAL_ARGUMENT_ERROR if the converter is
|
|
|
|
* null. or if the number of bytes provided are not in the codepage's range (e.g length 1 for ucs-2)
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
void setSubstitutionChars(const char* subChars,
|
|
|
|
int8_t len,
|
|
|
|
UErrorCode& err);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the state of stateful conversion to the default state. This is used
|
|
|
|
* in the case of error to restart a conversion from a known default state.
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
void resetState(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the name of the converter (zero-terminated).
|
|
|
|
* the name will be the internal name of the converter
|
|
|
|
* @param err the error status code. U_INDEX_OUTOFBOUNDS_ERROR in the converterNameLen is too
|
|
|
|
* small to contain the name.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @return the name of the converter.
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
const char* getName( UErrorCode& err) const;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* IBM registered codepages and return zero for the codepage number.
|
|
|
|
* The error code fill-in parameter indicates if the codepage number is available.
|
|
|
|
* @param err the error status code. U_ILLEGAL_ARGUMENT_ERROR will returned if
|
|
|
|
* the converter is null or if converter's data table is null.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @return the converter's codepage number. If any error occurrs, null will be returned.
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
int32_t getCodepage(UErrorCode& err) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current setting action taken when a character from a codepage
|
2000-07-14 01:00:59 +00:00
|
|
|
* is missing or a byte sequence is illegal etc.
|
|
|
|
* @param action the callback function pointer
|
|
|
|
* @param context the callback function state
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-07-14 01:00:59 +00:00
|
|
|
void getMissingCharAction(UConverterToUCallback *action,
|
2001-06-26 22:51:14 +00:00
|
|
|
const void **context) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-07-14 01:00:59 +00:00
|
|
|
* Return the current setting action taken when a unicode character is missing
|
|
|
|
* or there is an unpaired surrogate etc.
|
|
|
|
* @param action the callback function pointer
|
|
|
|
* @param context the callback function state
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-07-14 01:00:59 +00:00
|
|
|
void getMissingUnicodeAction(UConverterFromUCallback *action,
|
2001-06-26 22:51:14 +00:00
|
|
|
const void **context) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the current setting action taken when a character from a codepage is
|
|
|
|
* missing. (Currently STOP or SUBSTITUTE).
|
2000-06-27 20:47:56 +00:00
|
|
|
* @param newAction the action constant if an equivalent codepage character is missing
|
|
|
|
* @param newContext the new toUnicode callback function state
|
|
|
|
* @param oldAction the original action constant, saved for later restoration.
|
|
|
|
* @param oldContext the old toUnicode callback function state
|
|
|
|
* @param err the error status code
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-06-27 20:47:56 +00:00
|
|
|
void setMissingCharAction(UConverterToUCallback newAction,
|
2001-06-26 22:51:14 +00:00
|
|
|
const void* newContext,
|
2000-07-05 20:56:42 +00:00
|
|
|
UConverterToUCallback *oldAction,
|
2001-06-26 22:51:14 +00:00
|
|
|
const void** oldContext,
|
1999-12-28 23:39:02 +00:00
|
|
|
UErrorCode& err);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the current setting action taken when a unicode character is missing.
|
|
|
|
* (currently T_UnicodeConverter_MissingUnicodeAction is either STOP or SUBSTITUTE,
|
|
|
|
* SKIP, CLOSEST_MATCH, ESCAPE_SEQ may be added in the future).
|
2000-06-27 20:47:56 +00:00
|
|
|
* @param newAction the action constant if an equivalent Unicode character is missing
|
|
|
|
* @param newContext the new fromUnicode callback function state
|
|
|
|
* @param oldAction the original action constant, saved for later restoration.
|
|
|
|
* @param oldContext the old fromUnicode callback function state
|
1999-12-28 23:39:02 +00:00
|
|
|
* @param err the error status code
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
2000-06-27 20:47:56 +00:00
|
|
|
void setMissingUnicodeAction(UConverterFromUCallback newAction,
|
2001-06-26 22:51:14 +00:00
|
|
|
const void* newContext,
|
2000-07-05 20:56:42 +00:00
|
|
|
UConverterFromUCallback *oldAction,
|
2001-06-26 22:51:14 +00:00
|
|
|
const void** oldContext,
|
1999-12-28 23:39:02 +00:00
|
|
|
UErrorCode& err);
|
|
|
|
/**
|
|
|
|
* Returns the localized name of the UnicodeConverter, if for any reason it is
|
|
|
|
* available, the internal name will be returned instead.
|
|
|
|
* @param displayLocale the valid Locale, from which we want to localize
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param displayName a UnicodeString that is going to be filled in.
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
void getDisplayName(const Locale& displayLocale,
|
|
|
|
UnicodeString& displayName) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the T_UnicodeConverter_platform (ICU defined enum) of a UnicodeConverter
|
|
|
|
* available, the internal name will be returned instead.
|
|
|
|
* @param err the error code status
|
|
|
|
* @return the codepages platform
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
UConverterPlatform getCodepagePlatform(UErrorCode& err) const;
|
|
|
|
|
2002-07-03 12:05:56 +00:00
|
|
|
/**
|
|
|
|
* Assignment operator.
|
|
|
|
* @param that object to be copied
|
|
|
|
* @return the newly created Unicode Converter.
|
|
|
|
*/
|
2000-08-01 00:44:15 +00:00
|
|
|
UnicodeConverter& operator=(const UnicodeConverter& that);
|
2002-07-03 12:05:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true when both UnicodeConveters refer to the same
|
|
|
|
* character in the same character-storage object.
|
|
|
|
* @param that The UnicodeConverter to be compared for equality
|
|
|
|
* @return true when both UnicodeConverters refer to the same
|
|
|
|
* character in the same character-storage object
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2002-07-03 12:05:56 +00:00
|
|
|
*/
|
2000-08-01 00:44:15 +00:00
|
|
|
UBool operator==(const UnicodeConverter& that) const;
|
2002-07-03 12:05:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true when the UnicodeConverters refer to different
|
|
|
|
* text-storage objects, or to different characters in the
|
|
|
|
* same text-storage object.
|
|
|
|
* @param that The UnicodeConverter to be compared for inequality
|
|
|
|
* @Returns true when the iterators refer to different
|
|
|
|
* text-storage objects, or to different characters in the
|
|
|
|
* same text-storage object
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2002-07-03 12:05:56 +00:00
|
|
|
*/
|
2000-08-01 00:44:15 +00:00
|
|
|
UBool operator!=(const UnicodeConverter& that) const;
|
2002-07-03 12:05:56 +00:00
|
|
|
|
|
|
|
/* copy constructor
|
|
|
|
* @param that The UnicodeConverter to be copied.
|
|
|
|
* @return the newly created Unicode Converter.
|
|
|
|
* */
|
2000-08-01 00:44:15 +00:00
|
|
|
UnicodeConverter(const UnicodeConverter& that);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the available names. Lazy evaluated, Library owns the storage
|
|
|
|
* @param num the number of available converters
|
|
|
|
* @param err the error code status
|
|
|
|
* @return the name array
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
static const char* const* getAvailableNames(int32_t& num,
|
|
|
|
UErrorCode& err);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Iterates through every cached converter and frees all the unused ones
|
|
|
|
* @return the number of cached converters successfully deleted
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
static int32_t flushCache(void);
|
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.
|
|
|
|
* @param source the input buffer to be fixed
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
2000-01-08 00:51:44 +00:00
|
|
|
*/
|
|
|
|
void fixFileSeparator(UnicodeString& source) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if the converter contains ambiguous mappings of the same
|
|
|
|
* character or not.
|
|
|
|
* @return TRUE if the converter contains ambiguous mapping of the same
|
|
|
|
* character, FALSE otherwise.
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
2000-01-08 00:51:44 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool isAmbiguous(void) const;
|
2000-01-08 00:51:44 +00:00
|
|
|
|
2002-06-29 00:04:16 +00:00
|
|
|
/**
|
|
|
|
* ICU "poor man's RTTI", returns a UClassID for the actual class.
|
|
|
|
*
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
2002-06-29 00:04:16 +00:00
|
|
|
*/
|
|
|
|
virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
|
2000-08-01 00:44:15 +00:00
|
|
|
|
2002-06-29 00:04:16 +00:00
|
|
|
/**
|
|
|
|
* ICU "poor man's RTTI", returns a UClassID for this class.
|
|
|
|
*
|
2002-12-05 23:26:26 +00:00
|
|
|
* @obsolete ICU 2.4. Use the parallel ucnv_ C API instead since this API will be removed in that release.
|
2002-06-29 00:04:16 +00:00
|
|
|
*/
|
|
|
|
static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The address of this static class variable serves as this class's ID
|
|
|
|
* for ICU "poor man's RTTI".
|
|
|
|
*/
|
|
|
|
static const char fgClassID;
|
|
|
|
};
|
2000-08-01 00:44:15 +00:00
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
2002-08-21 22:38:33 +00:00
|
|
|
#else
|
|
|
|
|
2002-12-05 23:26:26 +00:00
|
|
|
#error "The unicode/convert.h header is obsolete. Please use the converter C API in unicode/ucnv.h instead."
|
2002-08-21 22:38:33 +00:00
|
|
|
|
2002-08-21 19:12:24 +00:00
|
|
|
#endif /* ICU_UNICODECONVERTER_USE_DEPRECATES */
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
#endif
|