StringToBytes and BytesToString do some interesting things as part of their conversion. For instance, when converting to bytes, each character has 1 subtracted from it. On the other end, 1 is added back to each character. That alone makes it seem like you probably don’t want to use those functions if you’re looking for an exact representation of the string in bytes.
Another concern is that these methods don’t define an encoding for the characters in bytes. This is concerning if you wanted to pass the bytes to some other library that accepts an array of bytes that are to have a specific encoding.
You might find help looking into StringConv.h. In there, you will see two helper classes called FTCHARToUTF8 and FUTF8ToTCHAR. I’m not sure how well these are supported, but they appear to work in the following sample code.
void AMyActor::BeginPlay()
{
Super::BeginPlay();
FString InString(TEXT("TEST™TEST"));
FTCHARToUTF8 ToUtf8Converter(InString.GetCharArray().GetData());
auto Utf8StringSize = ToUtf8Converter.Length();
auto Utf8String = ToUtf8Converter.Get();
FUTF8ToTCHAR ToTCharConverter(Utf8String);
FString OutString(ToTCharConverter.Get());
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, InString);
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Blue, FString::FromInt(Utf8StringSize));
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Green, OutString);
}