锅炉信息网 > 锅炉知识 > 锅炉百科

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开源免费

精选推荐

  • 711关东煮供应商
    711关东煮供应商

    今天给大家介绍三位,奶粉,全家、罗森这些便利店里关东煮的供应商。店里卖三四块钱一串的关东煮,在网上买不到,一块钱就搞定。首先关东

  • 健康日历|高压锅容易爆炸的4个原因
    健康日历|高压锅容易爆炸的4个原因

    来源:医药养生保健报设计:李雅琴医学审核:姜峰出品人:胡丽丽

  • 高炉
    高炉

    今天这活却是个白事,等到了时辰,那家人便准备火化,本来准备送普炉,我却心中一动,便对那家人说道:“这老人走也不要省,还是送高炉吧。”

  • 高压锅和电压力锅的区别,推荐几款点压力锅
    高压锅和电压力锅的区别,推荐几款点压

    记得之前有一次去朋友家玩,他正在用高压锅煮小米粥,是的,高压锅压小米粥,大概煮了半小时,高压锅突然爆炸了,现场惨不忍睹啊,幸好厨房里没

0