1 USING: byte-arrays byte-vectors kernel io.encodings io.streams.string
2 sequences io namespaces io.encodings.private accessors ;
3 IN: io.streams.byte-array
5 : <byte-writer> ( encoding -- stream )
6 512 <byte-vector> swap <encoder> ;
8 : with-byte-writer ( encoding quot -- byte-array )
9 [ <byte-writer> ] dip [ output-stream get ] compose with-output-stream*
10 dup encoder? [ stream>> ] when >byte-array ; inline
12 : <byte-reader> ( byte-array encoding -- stream )
13 [ >byte-vector dup reverse-here ] dip <decoder> ;
15 : with-byte-reader ( byte-array encoding quot -- )
16 [ <byte-reader> ] dip with-input-stream* ; inline