Convert std::string to FString

Wow! Thanks for the kind words and for answering so quickly. I’m posting the two resulting utility functions, in case anybody else can make use of them:


char* fstring2charp(FString highLevelString) {
	std::string midLevelString(TCHAR_TO_UTF8(*highLevelString));
	char* lowLevelString = new char[midLevelString.size()+1];
	std::copy(midLevelString.begin(), midLevelString.end(), lowLevelString);
	return lowLevelString;
}

FString charp2fstring(char* lowLevelString){
	std::string midLevelString(lowLevelString);
	FString highLevelString(FString(midLevelString.c_str()));
	return highLevelString;
}

I’m aware they are more verbose than they would need to be, I’ve left them like that for clarity’s sake. Also, I’m not exactly sure what happens on the memory management level; for instance, can we call delete on the resulting pointer of a call to fstring2charp?

Don’t forget to #include <string>, <algorithm>