代码语言:javascript复制
FString a = "NingStudio";
//FString to std::string
std::string cstr(TCHAR_TO_UTF8(*a));
//std::string to FString
FString a = FString(cstr.c_str());
string转为TCHAR
代码语言:javascript复制void string2tchar(std::string &src, TCHAR* buf)
{
#ifdef UNICODE
_stprintf_s(buf, MAX_PATH, _T("%S"), src.c_str());//%S宽字符
#else
_stprintf_s(buf, MAX_PATH, _T("%s"), src.c_str());//%s单字符
#endif
}