I’m trying to write an FTimeSpan to string, I added some zero padding and saved it as an FString.
const TCHAR* time = *FormatTime(timeAtPause);
UE_LOG(LogClass, Log, TEXT("%s"), time);
Here is format time:
FString AMorganFreemanActor::FormatTime(FTimespan time) {
FString result = PadZero(time.GetMinutes()) + ":" + PadZero(time.GetSeconds()) + ":" + (time.GetFractionMilli()+"");
const TCHAR* myResult = *result;
return myResult;
}
I think that dereferencing FString causes the weird characters instead of numbers. I’m not sure how to cast FString to TCHAR. In Java it would be aString.toCharArray() ;
non-portable use of class 'FString' as an argument to a variadic function
this:
const TCHAR* test = *timeAtPause.ToString(TEXT("%m:%s:%f"));
UE_LOG(LogTemp, Warning, TEXT("%s"), test);
is my attempt at converting.
When I try to convert , I get this again with the weird chars:
My guess is that it is the dereferencing that does it. From what I read , FString is a wrapper around TCHARs , so… it might work to take the characters out one by one and convert to tchar then reassemble. Unless there’s a better way.