WEB开发网
开发学院手机开发Symbian 开发 Symbian S60 平台简体汉字处理浅谈 阅读

Symbian S60 平台简体汉字处理浅谈

 2010-02-25 04:37:00 来源:WEB开发网   
核心提示:CleanupClosePushL(file);RFileReadStream StreamReadFromFile(file);CleanupClosePushL(StreamReadFromFile);HBufC* StreamData= HBufC::NewLC(StreamReadFromFile, 32);C

CleanupClosePushL(file);

RFileReadStream StreamReadFromFile(file);

CleanupClosePushL(StreamReadFromFile);

HBufC* StreamData= HBufC::NewLC(StreamReadFromFile, 32);

CleanupStack::PopAndDestroy(3); //file StreamReadFromFile StreamData

FileServerSession.Close();

得到的StreamData可以通过:

CAknInformationNote* InfoNote;

InfoNote = new ( ELeave ) CAknInformationNote;

InfoNote->ExecuteLD( *StreamData )

加以显示验证。

3.非UTF-8编码简体汉字串读写文件:

如前所述,非UTF8编码简体汉字串必须进行编码转换,主要有两种方法:

 1).将字串转换为Unicode编码写入文件后直接读取:

//转换后写文件

_LIT( KFileName, "\private\xxxxxxxx\aTextFile.txt" );

RFs FileServerSession;

User::LeaveIfError(FileServerSession.Connect());

RFile file;

if ( file.Replace(FileServerSession, KFileName, EFileWrite ) != KErrNone )

{

return;

}

CleanupClosePushL( file );

_LIT8( KNonUnicodeString, "简体汉字串");

TPtrC8 point8( KNonUnicodeString );

CCnvCharacterSetConverter* characterSetConverter=CCnvCharacterSetConverter::NewLC();

if( converter->PrepareToConvertToOrFromL(KCharacterSetIdentifierGbk,

iEikonEnv->FsSession()) == CCnvCharacterSetConverter::EAvailable )

{

}

else if ( characterSetConverter->PrepareToConvertToOrFromL(KCharacterSetIdentifierGb2312,

iEikonEnv->FsSession())!= CCnvCharacterSetConverter::EAvailable )

{

CleanupStack::PopAndDestroy();

User::Leave( KErrNotSupported );

}

TInt state=CCnvCharacterSetConverter::KStateDefault;

HBufC* UnicodeString = HBufC::NewL( point8 );

TPtr16 point16 = UnicodeString->Des();

上一页  1 2 3 4 5 6  下一页

Tags:Symbian 平台

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