问题描述
在下面的代码(摘要)中,WideCharToMultiByte
是Windows特定的功能。
是否使用 STL 或 Boost 替代了该功能?
//in function parameters: (...,WCHAR* szNameOfDll,...)
char szSourceTemp[MAX_PATH + 1] = {0};
WideCharToMultiByte(CP_ACP,szNameOfDLL,-1,szSourceTemp,MAX_PATH,NULL,NULL);
任何帮助表示赞赏!
解决方法
std::wctomb/std::wcstombs
std::mbtowc/std::mbstowcs
或
#include <boost/locale.hpp>
#include <iostream>
std::string utf8_string = to_utf<char>(latin1_string,"Latin1");
std::wstring wide_string = to_utf<wchar_t>(latin1_string,"Latin1");
std::string latin1_string= from_utf(wide_string,"Latin1");
std::string utf8_string2 = utf_to_utf<char>(wide_string);