Binary array to UTF-8

Hi,

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++)


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.

I tried changing the return line to


return FString(TCHAR_TO_UTF8(*cstr.c_str()));

It compiles…but it crashes…

Thanks VERY MUCH in advance.

Dan