【UE4 C++】FName、FString与FText相互转换

参考官方文档:https://docs.unrealengine.com/en-US/Programming/UnrealArchitecture/StringHandling/index.html

From

To

Example

FName

FString

TestHUDString = TestHUDName.ToString();

FName

FText

TestHUDText = FText::FromName(TestHUDName);

Warning: FName -> FText is valid in some cases, but be aware that the FNames's content will not benefit from the FText's "auto localization".

 

FString

FName

TestHUDName = FName(*TestHUDString);

Warning: FString -> FName is dangerous as the conversion is lossy as FName's are case insensitive.

 

FString

FText

TestHUDText = FText::FromString(TestHUDString);

Warning: FString -> FText is valid in some cases, but be aware that the FString's content will not benefit from the FText's "auto localization".

 

FText

FString

TestHUDString = TestHUDText.ToString();

Warning: FText -> FString is dangerous as it is a potentially lossy conversion for some languages.

 

FText

FName

There is no direct conversion from FText to FName. Instead, convert to FString and then to FName.

Warning: FText -> FString -> FName is dangerous as the conversion is lossy as FName's are case insensitive.

FString TCHAR* TestHUDCHAR = TestHUDString.GetCharArray().GetData();

 

 

你可能感兴趣的:(UE4,c++)