Hi,
I’ve been trying to find a way to construct a FString from a single TCHAR so far this is what I’ve come up with and I’d like to know if you guys have any better methods.
First method:
TCHAR c = 'A';
FString str = FString(1, &c);
UE_LOG(LogTemp, Warning, TEXT("%s"), *str);
Second method using TArray
TCHAR c = 'A';
TArray<TCHAR> arr = { c, '\0'}; //null terminator needed.
TCHAR* ArrPtr = &arr[0];
FString str = ArrPtr;
UE_LOG(LogTemp, Warning, TEXT("%s"), *str);
Edit:
Second method I can also use instead of TArray I guess.
TCHAR arr[] = {c, '\0'};
Third method:
FString str;
str.AppendChar(c);
Thank you.