clarified how to best read and write bytes

svn: r16372

original commit: 0bd8b828e93d882a570ab47cbaa99d8deaa1efe7
This commit is contained in:
Robby Findler 2009-10-19 20:10:25 +00:00
parent 05873b8c54
commit c115dc4ee2
2 changed files with 10 additions and 3 deletions

View File

@ -78,8 +78,13 @@ Returns the next floating-point value in the stream.
@defmethod[(get-unterminated-bytes [len (or/c (box/c exact-nonnegative-integer?) false/c) #f])
(or/c bytes? false/c)]{
Returns the next byte string from the stream. Reading from a bad
stream returns @scheme[#f] or @scheme[""].
Returns the next byte string from the stream. This is
the recommended way to read bytes back in from a stream;
use @method[editor-stream-in% put] with two arguments
(passing along the length of the bytes) to write out the bytes
to match this method.
Reading from a bad stream returns @scheme[#f] or @scheme[#""].
Note that when @method[editor-stream-out% put] is not given a byte
length, it includes an extra byte for a nul terminator; use

View File

@ -64,7 +64,9 @@ Writes @scheme[v], or @scheme[n] bytes of @scheme[v].
When @scheme[n] is supplied with a byte-string @scheme[v], use
@method[editor-stream-in% get-unterminated-bytes] to read the bytes
later.
later. This is the recommended way to write out bytes to
be easily read in later; use @method[editor-stream-in%
get-unterminated-bytes] to read the bytes back in.
If @scheme[n] is not supplied and @scheme[v] is a byte string, then
for historical reasons, the actual number of bytes written includes a