Previous: srfi string-ports rationale, Up: srfi string-ports [Index]
This specification is taken from the MacScheme Reference Manual.
Take a string and return an input port that delivers characters from the
string. The port can be closed by close-input-port
, though its
storage will be reclaimed by the garbage collector if it becomes
inaccessible.
Example:
(define p (open-input-string "(a . (b . c . ())) 34")) (input-port? p) => #t (read p) => (a b c) (read p) => 34 (eof-object? (peek-char p)) => #t
Return an output port that will accumulate characters for retrieval by
get-output-string
. The port can be closed by the procedure
close-output-port
, though its storage will be reclaimed by the
garbage collector if it becomes inaccessible.
(let ([q (open-output-string)] [x '(a b c)]) (write (car x) q) (write (cdr x) q) (get-output-string q)) => "a(b c)"
Given an output port created by open-output-string
, return a
string consisting of the characters that have been output to the port so
far.