Location:
utf.h
Link against: charconv.lib
CnvUtfConverter
Supported from 5.1
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.
Defined in CnvUtfConverter
:
Anonymous
, ConvertFromUnicodeToUtf7()
, ConvertFromUnicodeToUtf8()
, ConvertToUnicodeFromUtf7()
, ConvertToUnicodeFromUtf8()
, EErrorIllFormedInput
, KStateDefault
, TError
static TInt ConvertFromUnicodeToUtf7(TDes8& aUtf7, const TDesC16& aUnicode, TBool aEncodeOptionalDirectCharactersInBase64);
Converts Unicode text into UTF-7 encoding.
|
|
static TInt ConvertFromUnicodeToUtf8(TDes8& aUtf8, const TDesC16& aUnicode, TBool aGenerateJavaConformantUtf8=EFalse);
Withdrawn in 6.0
Converts Unicode text into UTF-8 encoding.
The variant of UTF-8 used internally by Java differs slightly
from standard UTF-8. The TBool
argument controls the UTF-8 variant
generated by this function.
|
|
static TInt ConvertFromUnicodeToUtf8(TDes8& aUtf8, const TDesC16& aUnicode);
Supported from 6.0
Converts Unicode text into UTF-8 encoding.
|
|
static TInt ConvertToUnicodeFromUtf7(TDes16& aUnicode, const TDesC8& aUtf7, TInt& aState);
Converts text encoded using the Unicode transformation format UTF-7 into the Unicode UCS-2 character set.
If the conversion is achieved using a series of calls to this
function, where each call starts off where the previous call reached in the
input descriptor, the state of the conversion is stored. The initial value of
the state variable should be set as KStateDefault
when the
conversion is started, and afterwards simply passed unchanged into each
function call.
|
|
static TInt ConvertToUnicodeFromUtf8(TDes16& aUnicode, const TDesC8& aUtf8);
Converts text encoded using the Unicode transformation format UTF-8 into the Unicode UCS-2 character set.
|
|
TError
Conversion error flags. At this stage there is only one error flag — others may be added in the future.
|
Anonymous
Initial state for a piece-by-piece conversion of a UTF-8 string to Unicode.
|