UE4 c++编程中FName,FString,FText相互转换

From

To

Example

FName

FString

TestHUDString = TestHUDName.ToString();

FName

FText

TestHUDText = FText::FromName(TestHUDName);

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);

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

FString

FText

TestHUDText = FText::FromString(TestHUDString);

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();

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.

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

转自官网https://docs.unrealengine.com/en-us/Programming/UnrealArchitecture/StringHandling 官网真的吊~

你可能感兴趣的:(UE4)