UE4中FString转UTF8及UTF8转FString

时间:2023-03-09 15:43:10
UE4中FString转UTF8及UTF8转FString

FString转UTF8

 FString szMsg = "test msg";
TCHAR* pSendData = szMsg.GetCharArray().GetData();
int32 nDataLen = FCString::Strlen(pSendData);
uint8* dst = (uint8*)TCHAR_TO_UTF8(pSendData);

UTF8转FString

  TArray<uint8> receiveBuff;
 RecvData(receiveBuff, buffLen));
receiveBuff.Add('\0');
FString str = FString(reinterpret_cast<const char*>(receiveBuff.GetData()));