Is there a better way than the below example?
Example -
#include <strings>
char arr[ ] = "some char array";
string str(arr);
FString Fs(arr.c_str());
UE_LOG(LogActor, Error,TEXT("result = %s"), *Fs);
Is there a better way than the below example?
Example -
#include <strings>
char arr[ ] = "some char array";
string str(arr);
FString Fs(arr.c_str());
UE_LOG(LogActor, Error,TEXT("result = %s"), *Fs);
I would recommend using the decode macros:
FString Fs = FString(ANSI_TO_TCHAR(arr));
FString Fs = FString(UTF8_TO_TCHAR(arr));
There are plenty of macros. Make sure you terminare your char array with the null terminator ‘\0’.
Cheers,
Moss
What if you’re trying to convert a TArray instance to an FString? I can’t find documentation for how to do that. It should be simple since an FString has a TCHAR array under the hood anyways right?
Nevermind: I was trying to take a TArray and convert it into FString. But now I’m just initializing an empty FString instance, and then adding 1 character at a time to it using FStringInstance.AppendChar(TCHAR character).
I hope that’s an O(1) operation and not some O(N) operation where a new array has to be allocated…
It would be nice if the complexity of these operations were available.