s60的資料類型轉換

來源:互聯網
上載者:User

1.串轉換成數字TBuf16<20> buf(_L( "123" ) );TLex lex( buf );TInt iNum;lex.Val( iNum );

2.數字轉換成串TBuf16<20> buf;TInt iNum = 20;buf.Format( _L( "%d" ) , iNum );

3.將symbian串轉換成char串char* p = NULL;TBuf8<20> buf( _L( "aaaaa" ) );p = (char *)buf.Ptr(); 4.UTF-8轉換成UNICODECnvUtfConverter::ConvertToUnicodeFromUtf8( iBuf16 , iBuf8 );

5.UNICODE轉換成UTF-8CnvUtfConverter::ConvertFromUnicodeToUtf8( iBuf8 , iBuf16 ); 6.將char串轉換成symbian串char* cc = "aaaa";TPtrC8 a;a.Set( (const TUint8*)cc , strlen(cc) ); 再加一點:TDesC8 & buf ; TUint8 * pdata ; pdata = buf.Ptr() ; 然後,這個pdata就可以當成unsigned char *用了,這在網路通訊的時候很重要。如果,怕pdata破壞的話,可以TBuf8<1024>
tmp_buf ; tmp_buf.Copy(buf) ; pdata = tmp_buf.Ptr() ; 這樣就可以保護一下buf的資料了,尤其是如果這個buf是Socket的接收的資料是接收函數自己分配的時候。 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.