I’ve got a bit of C++ which gets data from a socket and creates a string from the binary array - can anyone help me to decode this as UTF8 on the way through?
I’m a bit of a C++ numpty so any help would be great.
I’ve poked around with TCHAR_to_UTF8 and FTCHARToUTF8 but i’m just generating error messages.
Here’s the code which turns the binary into the string. It’s something I originally got Rama to write for me but I thought with a fiddle I should be able to patch it. (And i’m trying to learn C++)
Code:
FString ARamaTCPReceiver::StringFromBinaryArray(const TArray<uint8>& BinaryArray)
{
//Create a string from a byte array!
const std::string cstr( reinterpret_cast<const char*>(BinaryArray.GetData()), BinaryArray.Num() );
return FString(cstr.c_str());
}
As it is i’m just getting question marks on the arabic characters i’m sending in - That’s not just in the console - it’s if I write it to a widget with a fully compatible font.
Let’s assume you have FString message, that is serialized like this (in your situation, this is the way message is converted before being sent via socket):
Please note that this solution is platform-specific. Thus, if you use platform, difeerent from Windows, keep in mind that there are some things that need to be adjusted.