WEB开发网
开发学院手机开发Symbian 开发 Symbian Base64 编码、解码的实现 阅读

Symbian Base64 编码、解码的实现

 2010-02-26 16:00:00 来源:WEB开发网   
核心提示:}if( buffer8 != NULL ){delete buffer8;buffer8 = NULL;}if( buffer16 != NULL ){delete buffer16;buffer16 = NULL;}}CBase64Handler* CBase64Handler::NewLC(){CBase64Ha

}

if( buffer8 != NULL )

{

delete buffer8;

buffer8 = NULL;

}

if( buffer16 != NULL )

{

delete buffer16;

buffer16 = NULL;

}

}

CBase64Handler* CBase64Handler::NewLC()

{

CBase64Handler* self = new (ELeave) CBase64Handler();

CleanupStack::PushL(self);

self->ConstructL();

return self;

}

CBase64Handler* CBase64Handler::NewL()

{

CBase64Handler* self = CBase64Handler::NewLC();

CleanupStack::Pop();

return self;

}

void CBase64Handler::ConstructL()

{

}

HBufC8* CBase64Handler::Base64EncodeLC( const TDesC8 & aSourceBuf )

{

TImCodecB64 B64;

buffer8 = HBufC8::NewL( aSourceBuf.Length() + aSourceBuf.Length()/3 );

B64.Initialise();

TPtr8 buffPtr = buffer8->Des();

B64.Encode( aSourceBuf, buffPtr );

return buffer8;

}

HBufC8* CBase64Handler::Base64DecodeLC( const TDesC8 & aSourceBuf )

{

TImCodecB64 B64;

buffer = HBufC8::NewLC( aSourceBuf.Length() );

B64.Initialise();

TPtr8 buffPtr = buffer->Des();

B64.Decode( aSourceBuf, buffPtr );

return buffer;

}

HBufC8* CBase64Handler::Base64EncodeLC( const TDesC16 & aSourceBuf )

{

buffer16 = HBufC8::NewLC( aSourceBuf.Length() );

buffer16->Des().Copy( aSourceBuf );

return Base64EncodeLC( *buffer16 );

}

/********************************************************************/

CBase64Handler* Handler = CBase64Handler::NewL();

HBufC8* encodeBuf = Handler->Base64EncodeLC(_L("this is test!"));

Tags:Symbian Base 编码

编辑录入:coldstar [复制链接] [打 印]
赞助商链接