|
|
|
Location:
convutils.h
Link against: convutils.lib
CnvUtilities
Supported from 6.0
Provides static character conversion utilities for complex
encodings. Its functions may be called from a plug-in DLL's implementation of
ConvertFromUnicode() and ConvertToUnicode().
These utility functions are provided for use when converting to/from complex character set encodings, including modal encodings. Modal encodings are those where the interpretation of a given byte of data is dependent on the current mode; mode changing is performed by escape sequences which occur in the byte stream. A non-modal complex encoding is one in which characters are encoded using variable numbers of bytes. The number of bytes used to encode a character depends on the value of the initial byte.
Defined in CnvUtilities:
ConvertFromIntermediateBufferInPlace(), ConvertFromUnicode(), ConvertFromUnicode(), ConvertToUnicodeFromHeterogeneousForeign(), ConvertToUnicodeFromHeterogeneousForeign(), ConvertToUnicodeFromModalForeign(), ConvertToUnicodeFromModalForeign(), FConvertFromIntermediateBufferInPlace, FConvertToIntermediateBufferInPlace, FNumberOfBytesAbleToConvert, SCharacterSet, SMethod, SState
static TInt ConvertFromUnicode(CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, TDes8& aForeign, const TDesC16& aUnicode, CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters, const TArray<SCharacterSet>& aArrayOfCharacterSets);
Converts Unicode text into a complex foreign character set
encoding. This is an encoding which cannot be converted simply by calling
CCnvCharacterSetConverter::DoConvertFromUnicode(). It may be modal
(e.g. JIS) or non-modal (e.g. Shift-JIS).
The Unicode text specified in aUnicode is
converted using the array of conversion data objects
(aArrayOfCharacterSets) provided by the plug-in for the complex
character set encoding, and the converted text is returned in
aForeign. Any existing contents in aForeign are
overwritten.
Unlike
CCnvCharacterSetConverter::DoConvertFromUnicode(), multiple
character sets can be specified. aUnicode is converted using the
first character conversion data object in the array. When a character is found
which cannot be converted using that data, each character set in the array is
tried in turn. If it cannot be converted using any object in the array, the
index of the character is appended to
aIndicesOfUnconvertibleCharacters and the character is replaced by
aReplacementForUnconvertibleUnicodeCharacters.
If it can be converted using another object in the array, that object is used to convert all subsequent characters until another unconvertible character is found.
|
|
static TInt ConvertFromUnicode(CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, TDes8& aForeign, const TDesC16& aUnicode, CCnvCharacterSetConverter::TArrayOfAscendingIndices& aIndicesOfUnconvertibleCharacters, const TArray<SCharacterSet>& aArrayOfCharacterSets, TUint& aOutputConversionFlags, TUint aInputConversionFlags);
Converts Unicode text into a complex foreign character set
encoding. This is an encoding which cannot be converted simply by a call to
CCnvCharacterSetConverter::DoConvertFromUnicode(). It may be modal
(e.g. JIS) or non-modal (e.g. Shift-JIS).
The Unicode text specified in aUnicode is
converted using the array of conversion data objects
(aArrayOfCharacterSets) provided by the plug-in for the complex
character set encoding and the converted text is returned in
aForeign. The function can either append to aForeign
or overwrite its contents (if any).
Unlike
CCnvCharacterSetConverter::DoConvertFromUnicode(), multiple
character sets can be specified. aUnicode is converted using the
first character conversion data object in the array. When a character is found
which cannot be converted using that data, each character set in the array is
tried in turn. If it cannot be converted using any object in the array, the
index of the character is appended to
aIndicesOfUnconvertibleCharacters and the character is replaced by
aReplacementForUnconvertibleUnicodeCharacters.
If it can be converted using another object in the array, that object is used to convert all subsequent characters until another unconvertible character is found.
|
|
static void ConvertFromIntermediateBufferInPlace(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut, const TDesC8& aEscapeSequence, TInt aNumberOfBytesPerCharacter);
Inserts an escape sequence into the descriptor.
This function is provided to help in the implementation of
ConvertFromUnicode() for modal character set encodings. Each
SCharacterSet object in the array passed to
ConvertFromUnicode() must have its
iConvertFromIntermediateBufferInPlace member assigned. To do this
for a modal character set encoding, implement a function whose signature
matches that of FConvertFromIntermediateBufferInPlace and which
calls this function, passing all arguments unchanged, and specifying the
character set's escape sequence and the number of bytes per character.
|
static TInt ConvertToUnicodeFromModalForeign(CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, TDes16& aUnicode, const TDesC8& aForeign, TInt& aState, TInt& aNumberOfUnconvertibleCharacters, TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter, const TArray<SState>& aArrayOfStates);
Converts text from a modal foreign character set encoding into Unicode.
The non-Unicode text specified in aForeign is
converted using the array of character set conversion objects
(aArrayOfStates) provided by the plug-in, and the converted text
is returned in aUnicode. Overwrites the contents, if any, of
aUnicode. The first element in aArrayOfStates is
taken to be the default mode (i.e. the mode to assume by default if there is no
preceding escape sequence).
|
|
static TInt ConvertToUnicodeFromModalForeign(CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, TDes16& aUnicode, const TDesC8& aForeign, TInt& aState, TInt& aNumberOfUnconvertibleCharacters, TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter, const TArray<SState>& aArrayOfStates, TUint& aOutputConversionFlags, TUint aInputConversionFlags);
Converts text from a modal foreign character set encoding into Unicode.
The non-Unicode text specified in aForeign is
converted using the array of character set conversion objects
(aArrayOfStates) provided by the plug-in, and the converted text
is returned in aUnicode. The function can either append to
aUnicode or overwrite its contents (if any), depending on the
input conversion flags specified. The first element in
aArrayOfStates is taken to be the default mode (i.e. the mode to
assume by default if there is no preceding escape sequence).
|
|
static TInt ConvertToUnicodeFromHeterogeneousForeign(CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, TDes16& aUnicode, const TDesC8& aForeign, TInt& aNumberOfUnconvertibleCharacters, TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter, const TArray<SMethod>& aArrayOfMethods);
Converts text from a non-modal complex character set encoding (e.g. Shift-JIS or EUC-JP) into Unicode.
The non-Unicode text specified in aForeign is
converted using the array of character set conversion methods
(aArrayOfMethods) provided by the plug-in, and the converted text
is returned in aUnicode. Overwrites the contents, if any, of
aUnicode.
|
|
static TInt ConvertToUnicodeFromHeterogeneousForeign(CCnvCharacterSetConverter::TEndianness aDefaultEndiannessOfForeignCharacters, TDes16& aUnicode, const TDesC8& aForeign, TInt& aNumberOfUnconvertibleCharacters, TInt& aIndexOfFirstByteOfFirstUnconvertibleCharacter, const TArray<SMethod>& aArrayOfMethods, TUint& aOutputConversionFlags, TUint aInputConversionFlags);
Converts text from a non-modal complex character set encoding (e.g. Shift-JIS, or EUC-JP) into Unicode.
The non-Unicode text specified in aForeign is
converted using the array of character set conversion methods
(aArrayOfMethods) provided by the plug-in, and the converted text
is returned in aUnicode. The function can either be set to append
to aUnicode, or overwrite its contents.
|
|
SCharacterSet
Character conversion data for one of the character sets which
is specified in a complex character set encoding. An array of these structs is
used when converting from Unicode to a complex character set encoding (see
CnvUtilities::ConvertFromUnicode()). None of the members may be
NULL.
Defined in CnvUtilities::SCharacterSet:
iConversionData, iConvertFromIntermediateBufferInPlace, iEscapeSequence
iConversionDataconst SCnvConversionData* iConversionData
The conversion data.
iConvertFromIntermediateBufferInPlaceFConvertFromIntermediateBufferInPlace iConvertFromIntermediateBufferInPlace
A pointer to a function which "mangles" the text in a way appropriate to the target complex character set. For instance it might insert a shifting character, escape sequence, or other special characters.
iEscapeSequenceconst TDesC8* iEscapeSequence
The escape sequence which introduces the character set, i.e. it identifies this character set as the next one to use. Must not be NULL. If the character set is non-modal, this should be set to an empty descriptor.
SState
Character conversion data for one of the character sets which
is specified in a modal character set encoding. An array of these structs is
used when converting from a modal character set into Unicode, using
CnvUtilities::ConvertToUnicodeFromModalForeign(). Neither of the
members may be NULL.
Defined in CnvUtilities::SState:
iConversionData, iEscapeSequence
iEscapeSequenceconst TDesC8* iEscapeSequence
The escape sequence which introduces the character set, i.e.
it identifies this character set as the next one to use. This must begin with
KControlCharacterEscape.
iConversionDataconst SCnvConversionData* iConversionData
The conversion data.
SMethod
Character conversion data for one of the character sets which
is specified in a non-modal complex character set encoding. An array of these
structs is used when converting from a non-modal complex character set encoding
into Unicode using
CnvUtilities::ConvertToUnicodeFromHeterogeneousForeign(). None of
the members may be NULL.
Defined in CnvUtilities::SMethod:
iConversionData, iConvertToIntermediateBufferInPlace, iNumberOfBytesAbleToConvert, iNumberOfBytesPerCharacter, iNumberOfCoreBytesPerCharacter
iNumberOfBytesAbleToConvertFNumberOfBytesAbleToConvert iNumberOfBytesAbleToConvert
A pointer to a function which calculates the number of
consecutive bytes in the remainder of the foreign descriptor which can be
converted using the current character set's conversion data. It may return a
negative CCnvCharacterSetConverter::TError value to indicate an
error in the encoding.
iConvertToIntermediateBufferInPlaceFConvertToIntermediateBufferInPlace iConvertToIntermediateBufferInPlace
A pointer to a function which prepares the text for conversion into Unicode. For instance it might remove any shifting or other special characters.
iConversionDataconst SCnvConversionData* iConversionData
The conversion data.
iNumberOfBytesPerCharacterTInt16 iNumberOfBytesPerCharacter
The number of bytes per character.
iNumberOfCoreBytesPerCharacterTInt16 iNumberOfCoreBytesPerCharacter
The number of core bytes per character.
typedef void (*FConvertFromIntermediateBufferInPlace)(TInt aStartPositionInDescriptor, TDes8& aDescriptor, TInt& aNumberOfCharactersThatDroppedOut);
A pointer to a function which "mangles" text when converting from Unicode into a complex modal or non-modal foreign character set encoding. It might insert a shifting character, escape sequence, or other special characters.
If the target character set encoding is modal, the
implementation of this function may call the
CnvUtilities::ConvertFromIntermediateBufferInPlace() utility
function which is provided because many modal character sets require an
identical implementation of this function.
typedef TInt (*FNumberOfBytesAbleToConvert)(const TDesC8& aDescriptor);
A pointer to a function which calculates the number of
consecutive bytes in the remainder of the foreign descriptor which can be
converted using the current character set's conversion data. Called when
converting from a non-modal complex character set encoding into Unicode. It may
return a negative CCnvCharacterSetConverter::TError value to
indicate an error in the encoding.
typedef void (*FConvertToIntermediateBufferInPlace)(TDes8& aDescriptor);
A pointer to a function which prepares the text for conversion into Unicode. For instance it might remove any shifting or other special characters. Called when converting from a non-modal complex character set encoding into Unicode.