ue4 fstring 和std::string互转

2021-11-10 15:08:38 浏览数 (1)

代码语言: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
}

0 人点赞