how to redirect printout into string?



In addition to a file, with_stdout accepts a stream as an output destination.
make_string_output_stream creates a Lisp string output stream.
get_output_stream_string returns the stream's content.
The latter 2 functions aren't documented; sorry, I guess that's an oversight.
(They were added a few years ago.)

e.g.
(%i6) S : make_string_output_stream ();
(%o6)                   #<OUTPUT STRING-OUTPUT-STREAM>
(%i7) with_stdout (S, print (HELLO));
(%o7)                                HELLO
(%i8) get_output_stream_string (S);
(%o8) HELLO

There is also make_string_input_stream.

HTH

Robert Dodier