CString->int
CString str("1234");
int i= _ttoi(str);
CString->const char *
const char* CXmlCtrl::cstoc(CString s)
{
int len = WideCharToMultiByte(CP_UTF8, 0, s, s.GetLength(), NULL, 0, NULL, NULL);
char * c = new char [len + 1];
len = WideCharToMultiByte(CP_UTF8, 0, s, s.GetLength(), c, len + 1, NULL, NULL);
c[len] = 0;
return (const char*)c;
}
WCHAR*->char*
void CXmlCtrl::w2c(char *pcstr,const wchar_t *pwstr, size_t len)
{
int nlength=wcslen(pwstr);
//获取转换后的长度
int nbytes = WideCharToMultiByte(0, 0, pwstr, nlength, NULL, 0, NULL, NULL );
if(nbytes>len)
nbytes=len;
// 通过以上得到的结果,转换unicode 字符为ascii 字符
WideCharToMultiByte(0, 0, pwstr, nlength, pcstr, nbytes, NULL, NULL );
}