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`.


• `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.



:Out <- BIN_OUTPUT.new
:P <- WRAP_PRINTER.new(Out CHARSET.utf8 "\r\n"){(:W)
stdout.print_line(Out.bin.repr) # => BIN.of(0x66 0x6f 0x6f 0x0d 0x0a)