Xml::CCharSetConverter Class Reference

class Xml::CCharSetConverter : public CBase

The CCharSetConverter class supplies algorithms for character conversion between a chosen character set and unicode. Memory management needed to hold the converted data is also handled.

CCnvCharacterSetConverter CnvUtfConverter MParser

Inherits from

Constructor & Destructor Documentation

CCharSetConverter()

CCharSetConverter ( ) [private]

Default Constructor

CCharSetConverter(const CCharSetConverter &)

CCharSetConverter ( const CCharSetConverter & aOriginal ) [private]

Parameters

const CCharSetConverter & aOriginal

~CCharSetConverter()

~CCharSetConverter ( ) [virtual]

Destructor. The framework is responsible for destroying this object.

Post-condition
This object is properly destroyed.

Member Functions Documentation

ConstructL()

void ConstructL ( ) [private]

This method provides some construction of this object.

ConvertCharacterSetIdentifierToStandardNameL(TUint32, HBufC8 *&)

IMPORT_C void ConvertCharacterSetIdentifierToStandardNameL ( TUint32 aCharSetUid,
HBufC8 *& aCharSet
)

This method is a helper function that obtains a standand character encoding name from a character set identifer.

CCnvCharacterSetConverter::ConvertCharacterSetIdentifierToStandardNameL
leave
KErrXmlUnsupportedCharacterSet If the character set is not known.

Parameters

TUint32 aCharSetUid The character set to obtain the name for.
HBufC8 *& aCharSet On return holds the Internet-standard name or MIME name of the character set. The name is encoded in 8 bit ASCII.

ConvertFromUnicodeL(const TDesC16 &, TUint32, HBufC8 *&)

IMPORT_C TInt ConvertFromUnicodeL ( const TDesC16 & aUnicodeConversion,
TUint32 aDestCharset,
HBufC8 *& aOutputBuffer
)

This method converts the given unicode to the specified encoding. If this function leaves, memory is cleaned up. This overload allocates memory for the output itself.

leave
KErrXmlUnavailableCharacterSet - Charset not available.

Parameters

const TDesC16 & aUnicodeConversion The unicode to convert.
TUint32 aDestCharset The character set encoding to convert to.
HBufC8 *& aOutputBuffer On return, contains the specified conversion.

ConvertFromUnicodeL(const TDesC16 &, TUint32, TPtr8 &)

IMPORT_C TInt ConvertFromUnicodeL ( const TDesC16 & aUnicodeConversion,
TUint32 aDestCharset,
TPtr8 & aOutput
)

This method converts the given unicode to the specified encoding. If this function leaves, memory is cleaned up. This overload stores the conversion output in memory already allocated, for the sole use of the TPtr versions of overloaded ConvertToUnicodeL and ConvertFromUnicodeL functions. You must make sure you have finished with the output from a previous call to either (TPtr overload of) ConvertToUnicodeL or ConvertFromUnicodeL before calling either again, as the previous output will be overwritten with the new output. This version is more efficient than the HBufC alternative and so should be used whenever possible.

leave
KErrXmlUnavailableCharacterSet - Charset not available.

Parameters

const TDesC16 & aUnicodeConversion The unicode to convert.
TUint32 aDestCharset The character set encoding to convert to.
TPtr8 & aOutput The characters after conversion.

ConvertToUnicodeL(TUint32, const TDesC8 &, HBufC16 *&)

IMPORT_C TInt ConvertToUnicodeL ( TUint32 aSrcCharset,
const TDesC8 & aInputBuffer,
HBufC16 *& aUnicodeConversion
)

This method converts the given bytes to unicode. If this function leaves, memory is cleaned up. This overload allocates memory for the output itself.

leave
KErrXmlUnavailableCharacterSet - CharSet not available.

Parameters

TUint32 aSrcCharset The character set encoding to convert from.
const TDesC8 & aInputBuffer The characters to be converted.
HBufC16 *& aUnicodeConversion On return, contains the unicode conversion.

ConvertToUnicodeL(TUint32, const TDesC8 &, TPtr16 &)

IMPORT_C TInt ConvertToUnicodeL ( TUint32 aSrcCharset,
const TDesC8 & aInputBuffer,
TPtr16 & aOutput
)

This method converts the given bytes to unicode. If this function leaves, memory is cleaned up. This overload stores the conversion output in memory already allocated, for the sole use of the TPtr versions of overloaded ConvertToUnicodeL and ConvertFromUnicodeL functions. You must make sure you have finished with the output from a previous call to either (TPtr overload of) ConvertToUnicodeL or ConvertFromUnicodeL before calling either again, as the previous output will be overwritten with the new output. This version is more efficient than the HBufC alternative and so should be used whenever possible.

leave
KErrXmlUnavailableCharacterSet - CharSet not available.

Parameters

TUint32 aSrcCharset The character set encoding to convert from.
const TDesC8 & aInputBuffer The characters to be converted.
TPtr16 & aOutput On return, contains the unicode conversion.

ConvertUcs4CharactersToEncodingL(TUint32 *, TInt, TUint32, HBufC8 *&)

IMPORT_C TInt ConvertUcs4CharactersToEncodingL ( TUint32 * aUcs4Src,
TInt aUcs4Count,
TUint32 aDestCharset,
HBufC8 *& aConversion
)

This method converts ucs-4 characters to the desired non-modal encoding. aConversion should be NULL on calling of this function. If this function leaves, memory is cleaned up. There is no TPtr overload of this method, as currently it is only called a few times and so would not produce any noticable benefits.

leave
KErrXmlBadCharacterConversion

Parameters

TUint32 * aUcs4Src list of ucs-4 characters.
TInt aUcs4Count number of ucs4 characters.
TUint32 aDestCharset the desired encoding.
HBufC8 *& aConversion On return, points to the converted encoding.

NewL()

CCharSetConverter * NewL ( ) [static]

This method creates an instance of this class. The framework is responsible for creating this object.

leave
... One of the system wide error codes e.g. KErrNoMemory

PrepareCharConvL(TUint &, const TDesC8 &)

IMPORT_C void PrepareCharConvL ( TUint & aCharSetUid,
const TDesC8 & aEncoding
)

This method prepares CharConv to encode from the standard name.

Post-condition
CharConv has been prepared.
leave
KErrXmlUnsupportedCharacterSet - Charset not supported.
leave
KErrXmlUnavailableCharacterSet - Charset not available

Parameters

TUint & aCharSetUid On return, contains the character set identifier of the encoding.
const TDesC8 & aEncoding the encoding to prepare for.

PrepareCharConvL(TUint &, TInt)

IMPORT_C void PrepareCharConvL ( TUint & aCharSetUid,
TInt aMibEnum
)

This method prepares CharConv to encode from the mib enum.

Post-condition
CharConv has been prepared.
leave
KErrXmlUnsupportedCharacterSet - Charset not supported.
leave
KErrXmlUnavailableCharacterSet - Charset not available
http://www.iana.org/assignments/character-sets

Parameters

TUint & aCharSetUid On return, contains the character set identifier of the encoding.
TInt aMibEnum The IANA specified mib enum for this encoding

PrepareToConvertToOrFromL(TUint32)

IMPORT_C void PrepareToConvertToOrFromL ( TUint32 aCharSetUid )

This method is a helper function that prepares CharConv for a conversion.

CCnvCharacterSetConverter::PrepareToConvertToOrFromL
Post-condition
CharConv is ready for the conversion or not.
leave
KErrXmlUnavailableCharacterSet - Charset not available.

Parameters

TUint32 aCharSetUid The character set encoding to convert to.

Utf32ToUtf16(TText16 *, TUint32)

TText16 * Utf32ToUtf16 ( TText16 * aUtf16Out,
TUint32 aUtf32
) [private]

This method converts a ucs-4 character to unicode.

Parameters

TText16 * aUtf16Out On return, contains the unicode character conversion.
TUint32 aUtf32 The ucs-4 character

operator=(const CCharSetConverter &)

CCharSetConverter & operator= ( const CCharSetConverter & aRhs ) [private]

Parameters

const CCharSetConverter & aRhs

Member Data Documentation

CCnvCharacterSetConverter * iCnvCharacterSetConverter

CCnvCharacterSetConverter * iCnvCharacterSetConverter [private]

The CharConv instance that we use to help in the character conversions.

TAny * iConversionBuffer

TAny * iConversionBuffer [private]

The buffer used to store the unicode conversion output.

TUint32 iConversionBufferSize

TUint32 iConversionBufferSize [private]

The size of the unicode conversion buffer.

RFs iFs

RFs iFs [private]

The File Server session handle.