CnvUtfConverter Class Reference

class CnvUtfConverter

Converts text between Unicode (UCS-2) and the two Unicode transformation formats UTF-7 and UTF-8. There are no functions to convert directly between UTF-7 and UTF-8.

Objects of this class do not need to be created because all the member functions are static. The four functions are passed text in the second argument and output the resulting text in the first argument. Sixteen-bit descriptors are used to hold text encoded in UCS-2 (i.e. normal 16 bit Unicode), and eight-bit descriptors are used to hold text encoded in either of the transformation formats.

The conversion functions return the number of characters which were not converted because the output descriptor was not long enough to hold all of the converted text. This allows users of this class to perform partial conversions on an input descriptor, handling the case when the input descriptor is truncated mid way through a multi-byte character. The caller does not have to guess how big to make the output descriptor for a given input descriptor- they can simply do the conversion in a loop using a small output descriptor. The ability to handle truncated descriptors is particularly useful if the caller is receiving information in chunks from an external source.

Member Functions Documentation

ConvertFromUnicodeToUtf7(TDes8 &, const TDesC16 &, TBool)

IMPORT_C TIntConvertFromUnicodeToUtf7(TDes8 &aUtf7,
const TDesC16 &aUnicode,
TBoolaEncodeOptionalDirectCharactersInBase64
)[static]

Parameters

TDes8 & aUtf7
const TDesC16 & aUnicode
TBool aEncodeOptionalDirectCharactersInBase64

ConvertFromUnicodeToUtf7(TDes8 &, const TDesC16 &, TBool, TBool)

TInt ConvertFromUnicodeToUtf7(TDes8 &aUtf7,
const TDesC16 &aUnicode,
TBoolaIsImapUtf7,
TBoolaEncodeOptionalDirectCharactersInBase64
)[static]

Parameters

TDes8 & aUtf7
const TDesC16 & aUnicode
TBool aIsImapUtf7
TBool aEncodeOptionalDirectCharactersInBase64

ConvertFromUnicodeToUtf7L(const TDesC16 &, TBool)

IMPORT_C HBufC8 *ConvertFromUnicodeToUtf7L(const TDesC16 &aUnicode,
TBoolaEncodeOptionalDirectCharactersInBase64
)[static]

Parameters

const TDesC16 & aUnicode
TBool aEncodeOptionalDirectCharactersInBase64

ConvertFromUnicodeToUtf8(TDes8 &, const TDesC16 &)

IMPORT_C TIntConvertFromUnicodeToUtf8(TDes8 &aUtf8,
const TDesC16 &aUnicode
)[static]

Parameters

TDes8 & aUtf8
const TDesC16 & aUnicode

ConvertFromUnicodeToUtf8(TDes8 &, const TDesC16 &, TBool)

TInt ConvertFromUnicodeToUtf8(TDes8 &aUtf8,
const TDesC16 &aUnicode,
TBoolaGenerateJavaConformantUtf8
)[static]

Parameters

TDes8 & aUtf8
const TDesC16 & aUnicode
TBool aGenerateJavaConformantUtf8

ConvertFromUnicodeToUtf8L(const TDesC16 &)

IMPORT_C HBufC8 *ConvertFromUnicodeToUtf8L(const TDesC16 &aUnicode)[static]

Parameters

const TDesC16 & aUnicode

ConvertToUnicodeFromUtf7(TDes16 &, const TDesC8 &, TInt &)

IMPORT_C TIntConvertToUnicodeFromUtf7(TDes16 &aUnicode,
const TDesC8 &aUtf7,
TInt &aState
)[static]

Parameters

TDes16 & aUnicode
const TDesC8 & aUtf7
TInt & aState

ConvertToUnicodeFromUtf7(TDes16 &, const TDesC8 &, TBool, TInt &)

TInt ConvertToUnicodeFromUtf7(TDes16 &aUnicode,
const TDesC8 &aUtf7,
TBoolaIsImapUtf7,
TInt &aState
)[static]

Parameters

TDes16 & aUnicode
const TDesC8 & aUtf7
TBool aIsImapUtf7
TInt & aState

ConvertToUnicodeFromUtf7L(const TDesC8 &)

IMPORT_C HBufC16 *ConvertToUnicodeFromUtf7L(const TDesC8 &aUtf7)[static]

Parameters

const TDesC8 & aUtf7

ConvertToUnicodeFromUtf8(TDes16 &, const TDesC8 &)

IMPORT_C TIntConvertToUnicodeFromUtf8(TDes16 &aUnicode,
const TDesC8 &aUtf8
)[static]

Parameters

TDes16 & aUnicode
const TDesC8 & aUtf8

ConvertToUnicodeFromUtf8(TDes16 &, const TDesC8 &, TBool)

TInt ConvertToUnicodeFromUtf8(TDes16 &aUnicode,
const TDesC8 &aUtf8,
TBoolaGenerateJavaConformantUtf8
)[static]

Parameters

TDes16 & aUnicode
const TDesC8 & aUtf8
TBool aGenerateJavaConformantUtf8

ConvertToUnicodeFromUtf8(TDes16 &, const TDesC8 &, TBool, TInt &, TInt &)

TInt ConvertToUnicodeFromUtf8(TDes16 &aUnicode,
const TDesC8 &aUtf8,
TBoolaGenerateJavaConformantUtf8,
TInt &aNumberOfUnconvertibleCharacters,
TInt &aIndexOfFirstByteOfFirstUnconvertibleCharacter
)[static]

Parameters

TDes16 & aUnicode
const TDesC8 & aUtf8
TBool aGenerateJavaConformantUtf8
TInt & aNumberOfUnconvertibleCharacters
TInt & aIndexOfFirstByteOfFirstUnconvertibleCharacter

ConvertToUnicodeFromUtf8L(const TDesC8 &)

IMPORT_C HBufC16 *ConvertToUnicodeFromUtf8L(const TDesC8 &aUtf8)[static]

Parameters

const TDesC8 & aUtf8

Member Enumerations Documentation

Enum TError

Conversion error flags. At this stage there is only one error flag
  • others may be added in the future.

Enumerators

EErrorIllFormedInput = KErrCorrupt

The input descriptor contains a single corrupt character. This might occur when the input descriptor only contains some of the bytes of a single multi-byte character.