char* and descriptors

Login to reply to this topic.
Thu, 2004-06-10 13:27
Joined: 2004-05-28
Forum posts: 30
I use library coded in plain C. It uses char* strings.   How shall I convert char* in symbian descriptors and back. I read topics about 8 and 16 bits descriptors but i suspect that char* and 8 bit one are not the same.

Thu, 2004-07-29 11:29
Anonymous (not verified)
Forum posts: 2043
char* and descriptors
there is no analogy for char * in symbian descriptors.
For const char* you can use TPtrC and for char[] you can use TBufC.
you can go through this link,  u will get a better idea.
http://www.newlc.com/article.php3?id_article=12&var_recherche=buffer+descriptors
Thu, 2004-07-29 12:01
Joined: 2004-07-10
Forum posts: 364
char* and descriptors
As they're in a library do you have to convert them?
C code will run if linked against the stdlib
Thu, 2004-07-29 13:00
Joined: 2004-06-16
Forum posts: 25
char* and descriptors
I didnt get exactly what type of conversion u r speaking about.
Regarding the descriptors you can use them directly except the abstract classes TDes and TBufcBase. U have to include the corressponding header file and lib file.
For eg.
#include <e32std.h>
_LIT16(KData,"abcdefg");
TBufC16<8> str(KData);
TBufC16<8> str2;
str2.Copy(str);
etc....

and include the lib file euser.lib in the .mmp file.
I think this is what u were looking for..........
Thu, 2004-08-05 10:20
Joined: 2004-06-15
Forum posts: 4
Re: char* and descriptors
Quote from: urrg
How shall I convert char* in symbian descriptors and back.

I used the following when converting a C string (const char*) to a Symbian descriptor:

Code:
const TUint8* fromStr = reinterpret_cast<const TUint8*>(aCString);
TPtrC8 ptr(fromStr);

HBufC8* destBuf = HBufC8::NewLC( strlen(aCString) );

TPtr8 dest(destBuf->Des());
dest.Copy(ptr);

It works for me.
Tue, 2004-12-28 21:17
Joined: 2004-12-19
Forum posts: 9
char* and descriptors
Just for the record,  I am calling into a function in a library ported from win32 that expects a (char *).  So here is the code I am using:

Code:

TBuf8<128> buf;
_LIT8(KConnIsNull, "Conn is NULL.  SQLError is (%d)");
buf.Format( KConnIsNull, my_Sqlca.GetSQLCode() );
the_ported_function( buf.PtrZ() );


where the_ported_function() has the signature:  the_ported_function(char *str);

Hope this helps,
mG.
  • Login to reply to this topic.