VARIANT转string VARIANT name;string Str; string Str = _com_util::ConvertBSTRToString(name.bstrVal);
TCHAR转string
string TCHAR2STRING(TCHAR *STR){
int iLen = WideCharToMultiByte(CP_ACP, 0,STR, -1, NULL, 0, NULL, NULL);
char* chRtn =new char[iLen*sizeof(char)];
WideCharToMultiByte(CP_ACP, 0, STR, -1, chRtn, iLen, NULL, NULL);
std::string str(chRtn);
return str;
}
QString转换String
string s = qstr.toStdString();
String转换QString
QString qstr2 = QString::fromStdString(s);
string字符串截取
string str = “1234”;
string s = str.substr(8, 17);//参数1 ,起始位,参数2截取数据位数
CString字符串截取
CString str = “1234”;
CString s = str.Mid(8, 17);//参数1 ,起始位,参数2截取数据位数
string转换大小写
string str;
transform(str.begin(), str.end(), str.begin(), :: toupper);//全部转为大写
transform(str.begin(), str.end(), str.begin(), :: tolower);//全部转为小写
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)