put-u8, write-u8 - write a byte to a binary output port
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs io ports)) ;R6RS
(import (scheme base)) ;R7RS
SYNOPSIS
(put-u8 binary-output-port byte) ;R6RS
(write-u8 byte) ;R7RS
(write-u8 byte binary-output-port) ;R7RS
DESCRIPTION
Writes the
byte
to the given
binary-output-port.
IMPLEMENTATION NOTES
- Chibi Scheme
-
The
current-output-port(3scm)
at program start is both textual and binary.
It should normally not be possible to use
write-u8
on the current output port before rebinding it to a binary output
port (which is not possible in R6RS).
RETURN VALUES
- R6RS
-
Returns unspecified values.
- R7RS
-
Returns a unspecified value.
EXAMPLES
;; R7RS code to create a file with the single line "A"
(call-with-port (open-output-file "test.txt")
(lambda (p)
(write-u8 65 p)
(write-u8 10 p)))
APPLICATION USAGE
Commonly used in applications that create binary files or other binary data.
There is often a mix of single bytes intermixed with larger writes with
put-bytevector(3scm).
ERRORS
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
-
The wrong number of arguments was passed or an argument was outside its domain.
In particular,
byte
must be an exact integer between 0 and 255.
- R7RS
-
The assertions described above are errors.
Implementations may signal an error, extend the procedure's
domain of definition to include such arguments,
or fail catastrophically.
SEE ALSO
put-char(3scm),
put-bytevector(3scm)
STANDARDS
R6RS,
R7RS
HISTORY
The
put-u8
procedure is new to the reworked I/O system introduced with R6RS.
The
write-u8
procedure is new in R7RS and is similar to
write-char(3scm)
but works with binary output ports, which did not exist in R5RS.
AUTHORS
This page is part of the
scheme-manpages
project.
It includes materials from the RnRS documents.
More information can be found at
https://github.com/schemedoc/manpages/
.
Markup created by unroff 1.0sc, March 04, 2023.