WEB开发网
开发学院手机开发Symbian 开发 Symbian 编码转换 GBK->Unicode 实现 阅读

Symbian 编码转换 GBK->Unicode 实现

 2010-03-15 19:42:00 来源:WEB开发网   
核心提示:分享下void ConvGbk2Uni(const TDesC8& original, TDes& res){RFs rFile;rFile.Connect();CCnvCharacterSetConverter* converter=CCnvCharacterSetConverter::NewLC();if(conv

分享下

void ConvGbk2Uni(const TDesC8& original, TDes& res)

{

RFs rFile;

rFile.Connect();

CCnvCharacterSetConverter* converter=CCnvCharacterSetConverter::NewLC();

if(converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierGbk,rFile)!=

CCnvCharacterSetConverter::EAvailable)

{

User::Leave(KErrNotSupported);

}

TInt state=CCnvCharacterSetConverter::KStateDefault;

TPtrC8 str( original );

HBufC* iInfoText = HBufC::NewL( str.Length() );

TPtr16 ptr = iInfoText->Des();

if(CCnvCharacterSetConverter::EErrorIllFormedInput ==

converter->ConvertToUnicode(ptr, str, state))

{

User::Leave(KErrArgument);

}

res.Zero() ;

res.Copy(ptr) ;

rFile.Close();

CleanupStack::PopAndDestroy();

delete iInfoText;

}

Tags:Symbian 编码 转换

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