4.60. kink/io/WRAP_PRINTER

Provides a printer implementation wrapping output.

4.60.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 <- BIN_OUTPUT.new
:P <- WRAP_PRINTER.new(Out CHARSET.utf8 "\r\n"){(:W)
  W.flush_on_print
}
P.print_line('foo')
stdout.print_line(Out.bin.repr) # => BIN.of(0x66 0x6f 0x6f 0x0d 0x0a)