Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Port Types   [Contents][Index]


6.14.10.2 Bytevector Ports

Scheme Procedure: open-bytevector-input-port bv [transcoder]
C Function: scm_open_bytevector_input_port (bv, transcoder)

Return an input port whose contents are drawn from bytevector bv (see Bytevectors).

The transcoder argument is currently not supported.

Scheme Procedure: open-bytevector-output-port [transcoder]
C Function: scm_open_bytevector_output_port (transcoder)

Return two values: a binary output port and a procedure. The latter should be called with zero arguments to obtain a bytevector containing the data accumulated by the port, as illustrated below.

(call-with-values
  (lambda ()
    (open-bytevector-output-port))
  (lambda (port get-bytevector)
    (display "hello" port)
    (get-bytevector)))

⇒ #vu8(104 101 108 108 111)

The transcoder argument is currently not supported.