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

  • Xml::CCharSetConverter

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()

voidConstructL()[private]

This method provides some construction of this object.

ConvertCharacterSetIdentifierToStandardNameL(TUint32, HBufC8 *&)

IMPORT_C voidConvertCharacterSetIdentifierToStandardNameL(TUint32aCharSetUid,
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 aCharSetUidThe character set to obtain the name for.
HBufC8 *& aCharSetOn 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 TIntConvertFromUnicodeL(const TDesC16 &aUnicodeConversion,
TUint32aDestCharset,
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 & aUnicodeConversionThe unicode to convert.
TUint32 aDestCharsetThe character set encoding to convert to.
HBufC8 *& aOutputBufferOn return, contains the specified conversion.

ConvertFromUnicodeL(const TDesC16 &, TUint32, TPtr8 &)

IMPORT_C TIntConvertFromUnicodeL(const TDesC16 &aUnicodeConversion,
TUint32aDestCharset,
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 & aUnicodeConversionThe unicode to convert.
TUint32 aDestCharsetThe character set encoding to convert to.
TPtr8 & aOutputThe characters after conversion.

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

IMPORT_C TIntConvertToUnicodeL(TUint32aSrcCharset,
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 aSrcCharsetThe character set encoding to convert from.
const TDesC8 & aInputBufferThe characters to be converted.
HBufC16 *& aUnicodeConversionOn return, contains the unicode conversion.

ConvertToUnicodeL(TUint32, const TDesC8 &, TPtr16 &)

IMPORT_C TIntConvertToUnicodeL(TUint32aSrcCharset,
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 aSrcCharsetThe character set encoding to convert from.
const TDesC8 & aInputBufferThe characters to be converted.
TPtr16 & aOutputOn return, contains the unicode conversion.

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

IMPORT_C TIntConvertUcs4CharactersToEncodingL(TUint32 *aUcs4Src,
TIntaUcs4Count,
TUint32aDestCharset,
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 * aUcs4Srclist of ucs-4 characters.
TInt aUcs4Countnumber of ucs4 characters.
TUint32 aDestCharsetthe desired encoding.
HBufC8 *& aConversionOn 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 voidPrepareCharConvL(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 & aCharSetUidOn return, contains the character set identifier of the encoding.
const TDesC8 & aEncodingthe encoding to prepare for.

PrepareCharConvL(TUint &, TInt)

IMPORT_C voidPrepareCharConvL(TUint &aCharSetUid,
TIntaMibEnum
)

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 & aCharSetUidOn return, contains the character set identifier of the encoding.
TInt aMibEnumThe IANA specified mib enum for this encoding

PrepareToConvertToOrFromL(TUint32)

IMPORT_C voidPrepareToConvertToOrFromL(TUint32aCharSetUid)

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 aCharSetUidThe character set encoding to convert to.

Utf32ToUtf16(TText16 *, TUint32)

TText16 *Utf32ToUtf16(TText16 *aUtf16Out,
TUint32aUtf32
)[private]

This method converts a ucs-4 character to unicode.

Parameters

TText16 * aUtf16OutOn return, contains the unicode character conversion.
TUint32 aUtf32The 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.