symbianc++各种类型之间的转换.docx

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Symbian C++ 各种类型之间的转换 2009-09-07 15:06 TTime 转 TBuf 型 TBuf32 theTime;// 存储转换后的时间 TTime tt; tt.HomeTime(); _LIT(KTimeFormat,%Y%M%D%1-%2-%3 %H:%T:%S);/ /格式为: 2006-03-04 12:12:12 tt.FormatL(theTime,KTimeFormat);//FormatL() 会以 KTimeFormat 字符串的形 式来格式化时间在赋值给 theTime TDateTime 转 TBuf 型 TTime currentTime;// 声明一个 TTime 类型 currentTime.HomeTime();// 设置 TTime 为当前时间 TDateTime tdt=currentTime.DateTime();//TTime --- TDateTime TBuf32 tmp;// 存储转换完的 Buf tmp.AppendNum(tdt.Year());〃 用 AppendNum(方法将一个 Tint 加入到 TBuf 中。 _LIT(dash,-);// 声明一个横线分隔年月日,同样可声明冒号分隔小时分秒 tmp.Append(dash); tmp.AppendNum(tdt.Month()); tmp.Append(dash); tmp.Appe ndNum(tdt.Day()); 时分秒的转换同上 TBuf 转 Tint 型 // 15 位数字 TInt iNum1(123456789009876); // 将缓存的内容设置为 iNum1 iBuf.Num(iNum1); // 使用 iBuf 包含的内容创建 TLex 对象 // the 15 digit number TLex iLex(iBuf); // iNum1 TInt iNum2; //iNum2 现在包含了 15 位数字 iLex.Val(iNum2); TInt 转 TBuf 型 TBuf10tmp; TInt ti=190; Tmp.AppendNum(ti); TBuf 转 TDateTime 型 将长的 TBuf 截成小段,分别是年月日时分秒,通过下面 TBuf 转 TInt ,再分别 把转换成Tint的年月日取出,通过 TDateTime的setYear (), setMonth () 等方法将时间 set 进 TDateTime 6. 其他转换 TBuf 转换为 TPtrC16 TBuf32 tText(_L(2004/11/05 05:44:00)); TPtrC16 tPtrSecond=tText.Mid(17,2); TPtrC16 转换为 TBufC16 TPtrC16 tPtrSecond=tText.Mid(17,2); TBufC1610 bufcs(tPtrSecond); TBufC16 转换为 TPtr16 TBufC1610 bufcs(tPtrSecond); TPtr16 f=bufcs.Des(); TPtr16 转换为 TBuf TBuf10 bufSecond; bufSecond.Copy(f); TBuf 转换为 TPtr16 TBuf10 bufSecond(_L(abc)); TPtr16 f; f.Copy(bufSecond); TBuf 转换为 Tint Tint aSecond; TLex iLexS(bufSecond); iLexS.Val(aSecond); Tint 转换为 TBuf TBuf32 tbuf; Tint i=200; tbuf.Num(i); 以下是S60的数据类型转换(巨有用) 将 symbian 串转换成 char 串 char* p = NULL; TBuf820 buf( _L( aaaaa ) ); p = (char *)buf.Ptr(); UTF-8 转换成 UNICODE CnvUtfConverter::ConvertToUnicodeFromUtf8( iBuf16 , iBuf8 ); UNIC0DE专换成 UTF-8 CnvUtfConverter::ConvertFromUnicodeToUtf8( iBuf8 , iBuf16 ); 将 char 串转换成 symbian 串 char* cc = aaaa; TPtrC8 a; a.Set( (const TUint8*)cc , strlen(cc) ); 再加一点: TDesC8 buf ; TUint8 * pdata ; pdata = buf.Ptr() ; 然后,这个 pdata 就可以当成 unsigned c

文档评论(0)

xiaozu + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档