sprintf-like Text Formatting

Maybe I’ve missed it, but is there sprintf-like text formatting somewhere? UE_LOG seems to use something of the sort, and I have looked at FText::Format, but the use seems a bit convoluted. I need something of the sort: FString gaga = SomeFormattingFunction("%0.2f Credits",myfloatvalue);, with adequate performance minimizing the need for caching (use in Slate, which seems to like to “get” values every frame).

If there are no engine provided functions, I’ll settle with sprintf or with one of these solutions.

FString::Printf() is what you’re looking for, I believe. There should be hundreds of examples in the engine.

Awesome, thanks.

You should really use FText::Format for anything that displays text to a human. FText::Format is localization aware, and allows things like reversing the order of strings for languages that have a different subject-verb-object order than your native language, whereas FString::Printf is limited to the order parameters are specified in. FText loc can also tag things as numbers, etc… if those have different localization rules, etc…

Michael Noland

Cool, I’ll keep that in mind when I tackle localization. Currently it’s just for displaying formatted numbers in scientific notation with units.