//将unicode下的wstring转化成ansi下的string
inline std::string UnicodeToASCII(LPCTSTR lpszText)
{
    int length=_tcslen(lpszText);

    TCHAR* pWideCharStr=new TCHAR[length+1];
    char* data=new char[2*length+2];

    _tcscpy(pWideCharStr, lpszText);

    WideCharToMultiByte(CP_ACP, 0, pWideCharStr, -1, data, 2*length + 2, NULL, NULL);

    std::string strText = data;

    delete []data;
    delete []pWideCharStr;

    return strText;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
猜你喜欢
  • 2021-06-29
  • 2022-12-23
  • 2021-09-22
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案