标签:dep unsigned static turn resize text acp als class
static std::wstring m2w(std::string ch, unsigned int CodePage = CP_ACP) { if (ch.empty())return L""; std::wstring ret; DWORD dwOutSize = 0; dwOutSize = MultiByteToWideChar(CodePage, 0, ch.c_str(), -1, NULL, 0); ret.resize(dwOutSize - 1); MultiByteToWideChar(CodePage, 0, ch.c_str(), ch.size(), &ret[0], dwOutSize); return ret; }
static std::string w2m(std::wstring wch, unsigned int CodePage = CP_ACP) { std::string ret; DWORD dwOutSize = 0; dwOutSize = WideCharToMultiByte(CodePage, 0, wch.c_str(), -1, NULL, 0, NULL, FALSE); char *pwText = 0; pwText = new char[dwOutSize]; pwText[dwOutSize - 1] = ‘\0‘; WideCharToMultiByte(CodePage, 0, wch.c_str(), wch.size(), pwText, dwOutSize, NULL, FALSE); ret = pwText; if (pwText)delete[]pwText; return ret; }
std::string name = w2m(m2w(obj->GetName(), CP_UTF8));//转换编码
std::wstring std::string w2m m2w
标签:dep unsigned static turn resize text acp als class
原文地址:https://www.cnblogs.com/herd/p/11140907.html