3.55. kink/io/WRAP_PRINTER

Provides a printer implementation wrapping output.

3.55.1. WRAP_PRINTER.new(Output Charset Newline ...[$config={}])

`new` makes a printer+output, which encodes str using `Charset`, and writes bin to `Output`.

Preconditions:

• `Output` must be an output

• `Charset` must be a charset

• `Newline` must be a str

• $config, if given, must be a fun which takes a conf val

The conf val provides the following method:

• C.flush_on_print : flushes bytes just after P.print or P.print_line are called. If C.flush_on_print is not called, the printer is not required to flush bytes just after .print or .print_line.

The result supports both printer and output types.

Example:

:BIN_OUTPUT.require_from('kink/io/')
:WRAP_PRINTER.require_from('kink/io/')
:CHARSET.require_from('kink/charset/')

[:Out :gen_bin] <- BIN_OUTPUT.make_pair
:P <- WRAP_PRINTER.new(Out CHARSET.utf8 "\r\n"){(:W)
  W.flush_on_print
}
P.print_line('foo')
stdout.print_line(gen_bin.repr) # => BIN.of(0x66 0x6f 0x6f 0x0d 0x0a)