mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-19 02:00:26 +02:00
Replace setbinary' by a public
%default-port-encoding' fluid.
* doc/ref/api-evaluation.texi (Character Encoding of Source Files): Add reference to the "Ports" node. * doc/ref/api-io.texi (Ports): Document `%default-port-encoding'. * libguile/ports.c (scm_port_encoding_var): Rename to... (default_port_encoding_var): ... this; update callers. Make `static'. * libguile/posix.c (scm_setbinary): Remove. * libguile/posix.h: Adjust accordingly. * test-suite/tests/numbers.test: Remove unneeded `setbinary' call. * test-suite/tests/ports.test: Replace `setbinary' call by equivalent `%default-port-encoding' mutation and `set-port-encoding!' calls. * test-suite/tests/r6rs-ports.test: Replace `setbinary' call by equivalent `%default-port-encoding' mutation.
This commit is contained in:
parent
c2be4e891c
commit
d6a6989e08
8 changed files with 38 additions and 53 deletions
|
@ -666,14 +666,17 @@ and @code{UTF-32} may not be used because they are not compatible with
|
|||
ASCII.
|
||||
|
||||
@cindex read
|
||||
@cindex set-port-encoding!
|
||||
@cindex encoding
|
||||
@cindex port encoding
|
||||
@findex set-port-encoding!
|
||||
There might be a scenario in which one would want to read non-ASCII
|
||||
code from a port, such as with the function @code{read}, instead of
|
||||
with @code{load}. If the port's character encoding is the same as the
|
||||
encoding of the code to be read by the port, not other special
|
||||
handling is necessary. The port will automatically do the character
|
||||
encoding conversion. The functions @code{setlocale} or by
|
||||
@code{set-port-encoding!} are used to set port encodings.
|
||||
@code{set-port-encoding!} are used to set port encodings
|
||||
(@pxref{Ports}).
|
||||
|
||||
If a port is used to read code of unknown character encoding, it can
|
||||
accomplish this in three steps. First, the character encoding of the
|
||||
|
|
|
@ -111,6 +111,12 @@ Sets the character encoding that will be used to interpret all port
|
|||
I/O. @var{enc} is a string containing the name of an encoding.
|
||||
@end deffn
|
||||
|
||||
@defvr {Scheme Variable} %default-port-encoding
|
||||
A fluid containing containing @code{#f} or the name of the encoding to
|
||||
be used by default for newly created ports (@pxref{Fluids and Dynamic
|
||||
States}). The value @code{#f} is equivalent to @code{"ISO-8859-1"}.
|
||||
@end defvr
|
||||
|
||||
New ports are created with the encoding appropriate for the current
|
||||
locale if @code{setlocale} has been called or ISO-8859-1 otherwise,
|
||||
and this procedure can be used to modify that encoding.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue