In 5.6 FString::Printf can’t be used with non literal format strings (ie the old “trick” described in [Content removed] doesn’t work anymore).
We have a ton of format strings coming from assets, so that they are not literals.
What is the preferred approch in this case?
We can move to FString::Format, but how can we really format the single elements (such as specifiy an explicit type of an argument, or the number of leading zeros, and so on)? Specifically, what is the format string to use to mimic something like “%03d”?
Thanks.
Hi,
The Unreal FString::Format function does not appear to accept formatting arguments. You may have to handle the manipulating those arguments manually by rolling your own methods prior top passing the value into the format function.
If you can provide an example of what you are trying to achieve I can attempt to supply additional information.
Short of using other FString functions to sanitize the arguments ( e.g AppendInt(1) etc), you could look at modifying your engine to revert the offending change ( commit 6ed576a might be a good place to start investigating) or port the previous FString::Printf functionality from 5.5 into a plugin to be used under a different class name ( e.g MyFString::Printf and perform a sweeping text replacement where needed ), keeping in mind that the change to remove the insecure formatting arguments was made for a reason.
An example: I have landscape layer infos named “Layer_00”, “Layer_01” and so on in a project. “Layer 000”, “Layer 001”, in another.
Our 5.5 tools just take a Printf format string and an index, and get the correct layer name.
I need a 5.6 compatible method to update all c++ and blueprint tools and keep this customizability.