Konstantine Voytenko
BluSPAN project coordinator
Fishnest Ltd.
bluspan@gmail.com
Carbider | 20 January, 2009 11:41
RBuf8 buf8 ; RBuf16 buf16 ;
buf16.Copy(buf8);
HBufC8 *heap8;
HBufC *heap16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*heap8);
TBuf8 sourceBuf8 ; TBuf16 destBuf16 ;
TInt len = sourceBuf8.Length();
aOutDest.FillZ(len/2 ); // necessary to set the size memcpy((TAny *)destBuf16.Ptr(), (TAny *)sourceBuf8.Ptr(), len);
RBuf8 source ; RBuf dest ; // the same as Rbuf16 TInt destLength ; source.Create(100 );
// Receive the 8 bit descriptor from socket that contains 16 bit data iActiveSocket->RecvOneOrMore(source, 0, iStatus, iLen );
destLength = source.Length() / 2 ; // 16 bit chars instead of 8 bit
dest.CleanupClosePushL() ; // to Cleanup Stack dest.Create( destLength );
//Conversion CBinaryConverter::copy8BitInto16BitDescriptorL(source, dest );
// Show the note CAknInformationNote *iInfNote ; iInfNote = new (ELeave) CAknInformationNote(); iInfNote->ExecuteLD(dest );
CleanupStack::PopAndDestroy(&dest); // Pop RBuf from the Cleanup Stack
Connectivity, S60, Symbian C++ |
Previous |
Comments (3) |
Trackbacks (0)
wizard_hu_ | 20/01/2009, 21:05
Based on how 8-bit descriptors look like in the memory I would trust that [0] is word-aligned and try
TPtrC ptr16(static_cast(&buf8[0]),buf8.Size()/2);
Carbider | 21/01/2009, 13:14
Thanks for discussion guys!
With last suggestion I could repeat the trick in this manner:
const TUint8* tempBuf_1 = &buf8[0];
TUint8* tempBuf_2 = const_cast(tempBuf_1 );
TUint16* tempBuf_3 = (TUint16*)(tempBuf_2);
TPtrC ptr16(tempBuf_3, destLength);
buf16.Copy(ptr16);
TPckg* classes
laa-laa | 20/01/2009, 12:49
Note that there are the TPckg family of templated wrapper classes (TPckg, TPckgC, TPckgBuf) for packaging any fixed-size data (e.g. T class instances) in a 8-bit descriptor and extracting such packages.
Lauri