How to convert const char* to TDesC8?

Login to reply to this topic.
Wed, 2005-02-16 13:46
Joined: 2005-02-15
Forum posts: 12
Hi all,

I am new to Symbian programming, and trying to figure it out, but I can't. Please, help me!

Thank you in advance!

Sincerelly yours,
Balint Toth

Wed, 2005-02-16 14:58
Joined: 2004-12-03
Forum posts: 192
How to convert const char* to TDesC8?
Code:
TInt namelen;

namelen = User::StringLength(pString);
TPtrC8 tmp(pString,namelen);
pString is C-style string
Wed, 2005-02-16 15:00
Joined: 2005-02-03
Forum posts: 24
How to convert const char* to TDesC8?
here you go:

const char* CALLSENDER_EVENT;
TPtrC8 ptr((const TUint8*)CALLSENDER_EVENT));
Wed, 2005-02-16 18:05
Joined: 2005-02-15
Forum posts: 12
How to convert const char* to TDesC8?
Hello!

Thanks for the fast reply and your help, its fantastic, its working!:)

BTW I have an additional question: how can I convert a TDes to char*?

Thanks again in advance!

Best regards,
Balint Toth
Wed, 2005-02-16 18:24
Joined: 2005-02-15
Forum posts: 12
How to convert const char* to TDesC8?
Sorry, I wasn't clear enought.

So I got a number what I want to convert to a string. Under windows I do it with the

_fcvt

function, which is not supported under symbian. I saw that TDes has a .Num() function. But how can I add a value to the TDes (a string)?
Than I have to copy it back to a char* with

strcat.

(I am porting a c code.)

But I cannot add value to TDes, and cannot cast it to be able to copy it back.

Thanks for your help in advance!

Best regards,
Balint Toth
Thu, 2005-02-17 08:05
Joined: 2004-12-03
Forum posts: 192
How to convert const char* to TDesC8?
Code:
unsigned char*  IntToStr(int value, unsigned char* pString)
{
   TBuf8<10>   tmp;
   TInt        len;

   
   tmp.Num(value);

   len = tmp.Length();
   Mem::Copy(pString,tmp.Ptr(),len);
   pString[len] = 0;

   return pString;
}
Thu, 2005-02-17 11:06
Joined: 2005-02-15
Forum posts: 12
How to convert const char* to TDesC8?
Thank you Core for your fast and great help!!!

Best regards,
Balint Toth[HUN]
Thu, 2005-02-17 12:08
Joined: 2004-12-03
Forum posts: 192
How to convert const char* to TDesC8?
not at all Smiley
  • Login to reply to this topic.