how to go from CString to char []
-
can anyone tell me how to convert or mask a CString to a char [] i.e. (char new[]). In need to do this for my combo box. Thanks guys, Rod
Take a look at Strings on Pocket PC, Unicode and ANSI.
char* GetAnsiString(const CString &s, UINT nCodePage)
{
int nSize = s.GetLength();
char *pAnsiString = new char[nSize+1];WideCharToMultiByte(nCodePage, 0, s, nSize+1, pAnsiString, nSize+1, NULL, NULL);
return pAnsiString;
}CString strUnicode = _T("Some test string");
char *pAnsiString = GetAnsiString(strUnicode, CP_ACP);Regards, Daniel. -- FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE. ;)
-
Take a look at Strings on Pocket PC, Unicode and ANSI.
char* GetAnsiString(const CString &s, UINT nCodePage)
{
int nSize = s.GetLength();
char *pAnsiString = new char[nSize+1];WideCharToMultiByte(nCodePage, 0, s, nSize+1, pAnsiString, nSize+1, NULL, NULL);
return pAnsiString;
}CString strUnicode = _T("Some test string");
char *pAnsiString = GetAnsiString(strUnicode, CP_ACP);Regards, Daniel. -- FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE. ;)
Thanks Daniel , Worked great, do you know how to convert ctime to cstring? I am trying to get data from a datepicker and it gives me a CDateTimeCtrl.I think I have converted to a CTime but How do I convert that to a cString to write it to a file. Here is what I have for code. CString szChoice; CTime date; m_date.GetTime(date); szChoice = date.Format(L"%x"); fileRead(L"Date: " + szChoice+ " \r" ) Thanks, Rod
-
Thanks Daniel , Worked great, do you know how to convert ctime to cstring? I am trying to get data from a datepicker and it gives me a CDateTimeCtrl.I think I have converted to a CTime but How do I convert that to a cString to write it to a file. Here is what I have for code. CString szChoice; CTime date; m_date.GetTime(date); szChoice = date.Format(L"%x"); fileRead(L"Date: " + szChoice+ " \r" ) Thanks, Rod
CTime to CString:
CString szChoice;
CTime date;
m_date.GetTime(date);
//szChoice = date.Format(L"%x");
szChoice.Format(L"%02d.%02d.%02d", date.GetDay(), date.GetMonth(), dat.GetYear());
fileRead(L"Date: " + szChoice+ L"\r");and of course: A Date and Time formatter Regards, Daniel. -- FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE. ;)