首页 > 其他 > 详细

ws2s函数

时间:2015-05-13 16:07:03      阅读:174      评论:0      收藏:0      [点我收藏+]
std::string ws2s(const std::wstring& str)
{
    char*     pElementText;
    int    iTextLen;
    // wide char to multi char
    iTextLen = WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, NULL, 0, NULL, NULL);
    pElementText = new char[iTextLen + 1];
    memset((void*)pElementText, 0, sizeof(char)* (iTextLen + 1));
    ::WideCharToMultiByte(CP_ACP, 0, str.c_str(), -1, pElementText, iTextLen, NULL, NULL);
    std::string strText;
    strText = pElementText;
    delete[] pElementText;
    return strText;
}
std::string strKEy = ws2s(pKey);//pKey为WCHAR类型
    char pStr[256] = {0};
    strcpy_s(pStr, 256, strKEy.c_str());

 

ws2s函数

原文:http://www.cnblogs.com/wumac/p/4500576.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!