I am trying to run an external program in SBCL and capture its output. The output is binary data (png image), while SBCL insists on interpreting it as strings.
I tried several ways, for example
(trivial-shell:shell-command "/path/to/png-generator" :input "some input")
(with-input-from-string (input "some input")
(with-output-to-string (output)
(run-program "/path/to/png-generator" () :input input :output output))
(with-input-from-string (input "some input")
(flexi-streams:with-output-to-sequence (output)
(run-program "/path/to/png-generator" () :input input :output output))
But I get errors like
Illegal :UTF-8 character starting at byte position 0.
It seems to me that SBCL is trying to interpret binary data as text and decode it. How to change this behavior? I'm only interested in getting the octet vector.
Edit: since it is not clear from the text above, I would like to add that, at least in the case of a flexi stream, the type of the stream element is flexi-streams:octect(which is (unsigned-byte 8)). I would expect, at least in this case, run-programto read raw bytes without many problems. Instead, I get a message likeDon't know how to copy to stream of element-type (UNSIGNED-BYTE 8)