UE4 数据类型转化
FString TheString = "String"FString To Intint32 NewInt = FCString::Atoi(*TheString);FString To Floatfloat NewFlo
FString TheString = "String"
FString To Int
int32 NewInt = FCString::Atoi(*TheString);
FString To Float
float NewFloat = FCString::Atoi(*TheString);
FString To bool
bool bNewbool = TestString.ToBool();
FString To char*
TCHAR_TO_UTF8(*content)
FString To Tchar
MyTchar = *MyFString;
FString To uint8
TArray AMyActor::UintConvert()n{ntFString szMsg = "gest";ntTArray tr_int8;ntTCHAR* pSendData = szMsg.GetCharArray().GetData();ntint32 nDataLen = FCString::Strlen(pSendData);ntfor (int i=0;i
FString To FName
FName NewName = FName(*TheString);
FString To FText
FText NewText = FText::FromString(TheString);
FString To std::string (需要包含#include
或者#include
和using namespace std;)
std::string MyStdString(TCHAR_TO_UTF8(*TheString));
FString To MD5(FString)
FMD5::HashAnsiString(TEXT("someStuff"));
Int To FString
FString NewString = FString::FromInt(MyNewInt);
Float To FString
FString NewString = FString::SanitizeFloat(MyNewFloat);
FText To FString
FString NewString = TestText.ToString();
FName To FString
FString NewString = TestName.ToString();
uint8 To FString
FString AMyActor::UintConvert2()n{ntconst TArray& BinaryArray = {103, 116};nt//(Create a string from a byte array!)ntconst std::string cstr(reinterpret_cast(BinaryArray.GetData()), BinaryArray.Num());nt//(FString can take in the c_str() of a std::string)ntreturn FString(cstr.c_str());n}
std:string To FString
FString NewString(TestString.c_str());n//(示例std::string TestString = "TestString";)
char to FString
UTF8_TO_TCHAR(char)
TCHAR to FString
TCHAR* dd =TEXT("aa");nFString cc = dd;
TCHAR to std:string
for (TArray& ite : content)n{ntconst std::string cstr(reinterpret_cast(ite.GetData()),ite.Num());n}
FName To FText
NewText = FText::FromName(TestName);
枚举转字符串
templatenFString SlAiDataHandle::GetEnumValueAsString(const FString& Name, TEnum Value)n{ntconst UEnum* EnumPtr = FindObject(ANY_PACKAGE, *Name, true);ntif (!EnumPtr) {nttreturn FString("InValid");nt}ntreturn EnumPtr->GetNameStringByIndex((int32)Value);n}nnESecondCategory SecCategory;nFString CategoryName = GetEnumValueAsString(FString("ESecondCategory"), SecCategory);
字符串转枚举
templatenTEnum SlAiDataHandle::GetEnumValueFromString(const FString& Name, FString Value)n{ntconst UEnum* EnumPtr = FindObject(ANY_PACKAGE, *Name, true);ntif (!EnumPtr) {nttreturn TEnum(0);nt}ntreturn (TEnum)EnumPtr->GetIndexByName(FName(*FString(Value)));n}nnFString CategoryName;nESecondCategory SecCategory = GetEnumValueFromString(FString("ESecondCategory"), *CategoryName);
FString to FText的NSLOCTEXT
FText Message = FText::Format(nttNSLOCTEXT("UnrealClient", "{0}", "{1}"),nttFText::FromString(tips),nttFText::FromString(TEXT("aa"))nt);
char* to FString
char+=FString;
char to FString
FString.AppendChar(char);
上一篇:2J04精密合金2j4
下一篇:GPT4开源免费