FString to UTF-8 byte[]

Hi guys,

it feels like my problem is rather trivial but I can’t find an answer to it. It’s boils down to smth. very simple: I have an FString (e.g. serialized JSON object) which I would like to send over the network. Now, most of the internet protocols (and counterparties) expect their data in UTF-8 and UE4 uses UTF-16 (USC2) for internal string representation. So I tried following:

	FString EchoStr = TEXT("\"EncodingTest\":\"ABCDabcdÜÄÖßАБВГДабвгд\"");
	FTCHARToUTF8 EchoStrUtf8(*EchoStr);
	
	int32 DestLen = EchoStrUtf8.Length();

	int SentLen = libwebsocket_write(Wsi, (unsigned char*)(TCHAR_TO_UTF8(*EchoStr)), DestLen, LWS_WRITE_TEXT);

The test string contains some german umlauts and some cyrillic characters. Now what I receive at the other end (simple websockets server) is this:

"EncodingTest":"ABCDabcdÜÄÖß??????????"

Strangely enough umlauts made it but cyrillic characters didn’t.

My question is - is this even the way to do it? How does one convert an FString to UTF-8 and extracts the byte[] and it’s length? And if it is the way - why are some characters broken?

Thank you

Ok, question closed. The problem was actually on the server side.