PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

How to convert from TBUFC to TCHAR - Porting Issue

Hello

I would like to be able to convert betweeb TBufC and TCHAR[] and vice versa, but I am not sure how to go about this. I'm trying to port a GapiDraw project i did to symbian.

TBufC<TEXTMAX> ImportDirectoryName1;
_TCHAR ImportDirectoryName2[MAX_PATH];

I would really appreciate any help

Thanks
As you know symbian is a unicode os so it use 16bit value to rappresent a character. The stdlib port on symbian instead use 8bit for char so you sadly can't mix the two string formats.

I don't know if there is a utility function to convert between the two formats, on my app I usually convert it with a simple cast:

Code:

TBufC<TEXTMAX> symbian_str;
_TCHAR c_str[MAX_PATH];

int i = 0;
for (; i < symbian_str.Length(); i++)
c_str[i] = (_TCHAR)symbian_str[i];
c_str[i] = '\0';


_TCHAR on symbian os should be defined as a char (8bit). Be aware, if you try to convert a symbian_str with fancy unicode characters the conversion will result quite disappointing.