C++ wstring转string

wstring to string

 

string CUtility::TCHAR2char(TCHAR* tchStr)

{

    int iLen = 2*wcslen(tchStr);

    char* chRtn = new char[iLen+1];

    memset(chRtn, 0, iLen + 1);

    wcstombs(chRtn,tchStr,iLen+1);

    string str(chRtn);

    delete[] chRtn;

    return str;

} 

你可能感兴趣的:(String)