# String formatting

The unit at /lib/fmt.fs contains a few string formatting words. It also augments
the "IO" structs with proxies to formatting words, which capture the proxied
words using ":capture" [doc/sys/io].

One of the important formatting words of this unit is "printf". It takes a
format string, for example "hello %d" which contains placeholder elements
identified by the character '%' followed by a letter.

That formatting string must be preceded by a number of arguments equal to the
number of placeholders in the string, in reverse order. Example:

    3 2 1 S" hello %d %d %d" printf --> prints "hello 1 2 3"

The letter following the '%' chars determines how the argument is formatted and
these letters are supported (others produce an error):

    d - decimal
    x - 4b hexadecimal
    w - 2b hexadecimal
    b - 1b hexadecimal
    s - string
    z - null-terminated string
    c - char

There's also the .f" shortcut, which behaves like ." with formatting
capabilities:

    : foo .f" foo %d bar" ;
    42 foo --> prints "foo 42 bar"

## API

printf ( ... fmt -- )
  Interpolate "fmt" with the following elements of PS using the rules described
  above.

sprintf ( ... fmt -- str )
  Interpolate "fmt" with the following elements into a static buffer and yield
  the result as a string. Because this buffer is static, the string will be
  overwritten on the next "sprintf" call.

.f" ( "fmt" -- ) *I*
  Shortcut for "S" ..." printf". Can be compiled.

.x? ( n -- )
  Print "n" in hexadecimal with a width that depends on the value.

.sz ( bytes -- )
  Print a "human readable" size in bytes, such as "42K", "2G" etc.

## Proxies added to IO:

:.
:.x
:.x2
:.x1
:printf
