c++ 常用函数集锦
目录
1、string和wstring之间转换
1、string和wstring之间转换
std::string convertWStringToString(std::wstring wstr)
{
std::string str;
if (!wstr.empty())
{
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
str = converter.to_bytes(wstr);
}
return str;
}
std::wstring convertStringToWString(std::string wstr)
{
std::wstring str;
if (!wstr.empty())
{
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
str = converter.from_bytes(wstr);
}
return str;
}