string/format
core-api
cfunction
src/core/string.c on line 536, column 1
(string/format format & values)
Similar to C's `snprintf`, but specialized for operating with Janet
values. Returns a new string.
The following conversion specifiers are supported, where the upper
case specifiers generate upper case output:
* `c`: ASCII character.
* `d`, `i`: integer, formatted as a decimal number.
* `x`, `X`: integer, formatted as a hexadecimal number.
* `o`: integer, formatted as an octal number.
* `f`, `F`: floating point number, formatted as a decimal number.
* `e`, `E`: floating point number, formatted in scientific
notation.
* `g`, `G`: floating point number, formatted in its shortest form.
* `a`, `A`: floating point number, formatted as a hexadecimal
number.
* `s`: formatted as a string, precision indicates padding and
maximum length.
* `t`: emit the type of the given value.
* `v`: format with (describe x)
* `V`: format with (string x)
* `j`: format to jdn (Janet data notation).
The following conversion specifiers are used for "pretty-printing",
where the upper-case variants generate colored output. These
specifiers can take a precision argument to specify the maximum
nesting depth to print.
* `p`, `P`: pretty format, truncating if necessary
* `m`, `M`: pretty format without truncating.
* `q`, `Q`: pretty format on one line, truncating if necessary.
* `n`, `N`: pretty format on one line without truncation.