For some unit tests, I want to write to a binary list of codes. But it seems that with_output_to(codes(Stream), ...)
does some kind of encoding (UTF8, I suppose).
I can make my unit test with tmp_file_stream/3 and the option encoding(binary)
, but that’s a bit clumsy; it would be nice if I could set the encoding of a “codes” stream, but that gets the error “No permission to encoding stream ‘current_output’”. (And a minor incompatibility: tmp_file_stream/3 has encoding(binary)
but open/4, with_output_to/2, set_stream/2 have encoding(octet)
.)
Specifically, this is what I tried to do, and got an error:
with_output_to(codes(Codes),
( set_stream(current_output, encoding(octet)),
ffi_write_int64(current_output, V)
)),