Any Symbian Developer would always had his fight with understanding Descriptors and using them. Here is a few Descriptor Copying and Conversion code snippets for your Reference.
Just Copying from 8 bit to 16 bit Symbian Descriptor
HBufC16* buf16 = HBufC16::NewL( buf8->Length() );Descriptor Conversion without Data Modification (Just casting)
buf16->Des().Copy( *buf8);
Just Copying from 16 bit to 8 bit
HBufC8* buf8 = HBufC8::NewL( buf16->Length() );
buf8->Des().Copy( *buf16);
8-bit to 16-bit
TPtrC16 ptr16(reinterpret_cast(iBuf8.Ptr()),(iBuf8.Size()/2)); iBuf16=ptr16; 16-bit to 8-bit TPtrC8 ptr8(reinterpret_cast (iBuf16.Ptr()),(iBuf16.Size()*2)); iBuf8=ptr8;
Descriptor Conversion in Which Data is Modified (Convert each character)
Link against charconv.lib
#include "utf.h" 8-bit to 16-bit CnvUtfConverter::ConvertToUnicodeFromUtf8(iBuf16,iBuf8); 16-bit to 8-bit CnvUtfConverter::ConvertFromUnicodeToUtf8(iBuf8,iBuf16);
0 comments:
Post a Comment