1.TBuf 转 TInt 型
TInt iNum1(123456789009876);// 15位数字
iBuf.Num(iNum1); // 将缓存的内容设置为iNum1
TLex iLex(iBuf); // 使用iBuf包含的内容创建TLex对象the 15 digit number
TInt iNum2;
iLex.Val(iNum2); //iNum2现在包含了15位数字
2.TBuf 转换为 TPtrC16
TBuf<32> tText(_L("2004/11/05 05:44:00"));
TPtrC16 tPtrSecond = tText.Mid(17,2);
3.TPtrC16 转换为 TBufC16
TPtrC16 tPtrSecond = tText.Mid(17,2);
TBufC16<10> bufcs(tPtrSecond);
4.TBufC16 转换为 TPtr16
TBufC16<10> bufcs(tPtrSecond);
TPtr16 f = bufcs.Des();
5.TPtr16 转换为 TBuf
TBuf<10> bufSecond;
bufSecond.Copy(f);
6.TBuf 转换为 TPtr16
TBuf<10> bufSecond(_L("abc"));
TPtr16 f;
f.Copy(bufSecond);
7.TBuf 转换为 TInt
TInt aSecond;
TLex iLexS(bufSecond);
iLexS.Val(aSecond);
8.TInt 转换为 TBuf
TBuf<32> tbuf;
TInt i=200;
tbuf.Num(i);
9.UTF-8 转换成 UNICODE
CnvUtfConverter::ConvertToUnicodeFromUtf8(iBuf16, iBuf8);
10.UNICODE 转换成 UTF-8
CnvUtfConverter::ConvertFromUnicodeToUtf8(iBuf8, iBuf16);
11.将 char 串转换成 symbian 串
char* cc = "aaaa";
TPtrC8 a;
a.Set((const TUint8*)cc , strlen(cc));
12. 8位转16位
TBuf8 aCurrentAP;
...
HBufC *tempApn = HBufC::NewL(aCurrentAP.Length() * 2);
tempApn->Des().Copy(aCurrentAP);