summaryrefslogtreecommitdiff
path: root/doc/ref/api-io.texi
diff options
context:
space:
mode:
authorMichael Gran <spk121@yahoo.com>2010-07-17 03:45:28 -0700
committerMichael Gran <spk121@yahoo.com>2010-07-17 03:50:52 -0700
commit211683cc5c99542dfb6e2a33f7cb8c1f9abbc702 (patch)
treedf4d0a86e4f828b06f30f2bfddbd797c44d8caf6 /doc/ref/api-io.texi
parent2e67eb6f2d76e36350793a6f6e79d773f559f19c (diff)
downloadguile-211683cc5c99542dfb6e2a33f7cb8c1f9abbc702.tar.gz
open-file should handle binary mode and coding declarations
The open-file port should use the 8-bit ISO-8859-1 encoding when a file is opened using mode "b". Also, it should honor a "coding:" declaration at the top of a file when reading files where it is present. * libguile/fports.c (scm_open_file): modified * test-suite/tests/ports.test: more tests for open-file * doc/ref/api-io.texi (File Ports): more documentation for open-file
Diffstat (limited to 'doc/ref/api-io.texi')
-rw-r--r--doc/ref/api-io.texi18
1 files changed, 16 insertions, 2 deletions
diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi
index f09ecfbb4..83474a166 100644
--- a/doc/ref/api-io.texi
+++ b/doc/ref/api-io.texi
@@ -130,8 +130,8 @@ this fluid otherwise.
@deffn {Scheme Procedure} port-encoding port
@deffnx {C Function} scm_port_encoding
-Returns, as a string, the character encoding that @var{port} uses to
-interpret its input and output.
+Returns, as a string, the character encoding that @var{port} uses to interpret
+its input and output. The value @code{#f} is equivalent to @code{"ISO-8859-1"}.
@end deffn
@deffn {Scheme Procedure} set-port-conversion-strategy! port sym
@@ -856,11 +856,25 @@ systems, but has no effect on Unix-like systems.
(For reference, Guile leaves text versus binary up to the C library,
@code{b} here just adds @code{O_BINARY} to the underlying @code{open}
call, when that flag is available.)
+
+Also, open the file using the 8-bit character encoding "ISO-8859-1",
+ignoring any coding declaration or port encoding.
+
+Note that, when reading or writing binary data with ports, the
+bytevector ports in the @code{(rnrs io ports)} module are preferred,
+as they return vectors, and not strings (@pxref{R6RS I/O Ports}).
@end table
If a file cannot be opened with the access
requested, @code{open-file} throws an exception.
+When the file is opened, this procedure will scan for a coding
+declaration (@pxref{Character Encoding of Source Files}). If present
+will use that encoding for interpreting the file. Otherwise, the
+port's encoding will be used. To supress this behavior, open
+the file in binary mode and then set the port encoding explicitly
+using @code{set-port-encoding!}.
+
In theory we could create read/write ports which were buffered
in one direction only. However this isn't included in the
current interfaces.