fmt_text [function]
fmt_text( [int prealloc,] string text, ... )
parses all format specifiers in text
and returns the result
see string_format if you need position (argument index) specifications in the format string
prealloc
specifies number of bytes to be preallocated on the buffer to avoid continuous reallocations during string generation- the general format of a format specifier is as follows: {fmt[size][.prec][r][p<char>]}
- fmt: one-character output type (b-binary, o-octal, d-decimal, x/X-hexadecimal, f-floating-point, g/G-compact floating-point, e/E-scientific floating-point, s-valid string, c-always converted to string)
- size: minimum number of characters to print
- prec: precision of floating-point variables, string length limit
- r: add "r" to right-pad (left-justify)
- p<char>: add "p" and any character to set that character as the padding character (default: space/0x20)
- if anything unexpected happens, this function will emit a warning and put "#error#" in the place of a format specifier
print fmt_text( "{d} -> {x}", 1337, 1337 ); // prints "1337 -> 539" print fmt_text( "null: {d}, {s}, {c}", null, null, null ); // prints "null: #error#, #error#, null" and emits two warnings for item 1 and item 2 print fmt_text( "pi: {f10.10r} {g10r} {E10r}", M_PI, M_PI, M_PI ); // "pi: 3.1415926536 3.14159 3.141593E+000"