Hi sick. I spent some time exploring the source code, and it appears that the syntax format I mentioned above is the standard used throughout the source code. I am not sure if there is a way to avoid using the TEXT() macro entirely, but that does not appear to be the case.
There are few encoding conversion macros available AFAIK, there should be something like ANSI_TO_TCHAR among them, it would work for you to avoid TEXT() macro.
In the time since this post was first made, I have picked up a few more details about FStrings. If you simply need to convert an FString into TCHAR, you can do so by dereferencing the FString. For example, something like this would work: const TCHAR* TheMessage = *TheString;
However, as was noted in this post, that will not work within the UE_LOG macro. The reason for this is that the UE_LOG macro requires a string literal. The TEXT macro provides the literal, so it has to be used in this instance. Allowing an arbitrary string to be used in the UE_LOG macro can open a potential security hole.
What workaround would you suggest if the formatting string is a variable rather than a string literal? For example, if you want to use the same formatting string in several places like this case (which now gives a warning):
If the reason you don’t want to use the workaround is that you are sending a format string, and you want to follow the FString with formated vairables. Then what you would need is:
This will also work with a variadic template if that’s what you are looking for. That’s how I stumbled on this thread.
in such chase just paste std::forward(args)… into * your variables here*
For example I used it to create myself a template that encapsulates Timeout checking and error loging into a single template call: