diff options
author | Ludovic Courtès <ludo@gnu.org> | 2011-04-22 23:55:37 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2011-04-22 23:58:00 +0200 |
commit | 96128014bfaabe9e123c4f4928ce4c20427eaa53 (patch) | |
tree | ef27223b8abacbc5ab801b3029f91813fb575e87 /doc/ref/api-io.texi | |
parent | 969bb92e9b13068abadb22eb7ab13c7f6616d266 (diff) | |
download | guile-96128014bfaabe9e123c4f4928ce4c20427eaa53.tar.gz |
Make sure binary ports pass `binary-port?' regardless of the locale.
* libguile/r6rs-ports.c (make_bip, make_cbip, make_bop, make_cbop):
Set `c_port->encoding' to NULL.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input
Ports")["bytevector-input-port is binary"]: New test.
("7.2.7 Input Ports")["make-custom-binary-input-port"]: Make sure PORT
passes `binary-port?' and `input-port?'.
("8.2.10 Output ports")["bytevector-output-port is binary"]: New test.
["make-custom-binary-output"]: Rename to...
["make-custom-binary-output-port"]: ... this.
* test-suite/tests/ports.test ("string ports")["read-char, wrong
encoding, error", "read-char, wrong encoding, escape", "read-char,
wrong encoding, substitute", "peek-char, wrong encoding, error"]: Use
`set-port-encoding!' instead of `%default-port-encoding' to set the
encoding of bytevector input ports.
* test-suite/tests/rdelim.test ("read-line")["decoding error", "decoding
error, substitute"]: Likewise.
* doc/ref/api-io.texi (R6RS Port Manipulation): Document `binary-port?'
and `textual-port?'.
* doc/ref/r6rs.texi (R6RS Incompatibilities): Mention the soft
distinction between textual and binary ports.
Diffstat (limited to 'doc/ref/api-io.texi')
-rw-r--r-- | doc/ref/api-io.texi | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi index 02c184986..4786d79a4 100644 --- a/doc/ref/api-io.texi +++ b/doc/ref/api-io.texi @@ -1229,6 +1229,31 @@ Call @var{proc}, passing it @var{port} and closing @var{port} upon exit of @var{proc}. Return the return values of @var{proc}. @end deffn +@deffn {Scheme Procedure} binary-port? port +Return @code{#t} if @var{port} is a @dfn{binary port}, suitable for +binary data input/output. + +Note that internally Guile does not differentiate between binary and +textual ports, unlike the R6RS. Thus, this procedure returns true when +@var{port} does not have an associated encoding---i.e., when +@code{(port-encoding @var{port})} is @code{#f} (@pxref{Ports, +port-encoding}). This is the case for ports returned by R6RS procedures +such as @code{open-bytevector-input-port} and +@code{make-custom-binary-output-port}. + +However, Guile currently does not prevent use of textual I/O procedures +such as @code{display} or @code{read-char} with binary ports. Doing so +``upgrades'' the port from binary to textual, under the ISO-8859-1 +encoding. Likewise, Guile does not prevent use of +@code{set-port-encoding!} on a binary port, which also turns it into a +``textual'' port. +@end deffn + +@deffn {Scheme Procedure} textual-port? port +Always return @var{#t}, as all ports can be used for textual I/O in +Guile. +@end deffn + @node R6RS Binary Input @subsubsection Binary Input |