| make-transcoder(3scm) | Scheme Programmer's Manual | make-transcoder(3scm) |
NAME
make-transcoder, transcoder-codec, transcoder-eol-style, transcoder-error-handling-mode - port transcodersLIBRARY
(import (rnrs)) ;R6RS (import (rnrs io ports)) ;R6RS
SYNOPSIS
(make-transcoder codec) (make-transcoder codec eol-style) (make-transcoder codec eol-style handling-mode) (transcoder-codec transcoder) (transcoder-eol-style transcoder) (transcoder-error-handling-mode transcoder)
DESCRIPTION
Returns a transcoder with the behavior specified by the arguments.Codec must be a codec. The standard codecs are those returned by latin-1-codec, utf-8-codec, and utf-16-codec.
Eol-style is optional and must be an eol-style(3scm) symbol: lf, cr, crlf, nel, crnel, ls. or none. It defaults to the native end-of-line style of the underlying platform.
Handling-mode is optional and must be an error-handling-mode(3scm) symbol: ignore, raise, or replace (default).
IMPLEMENTATION NOTES
- IronScheme
- The native end-of-line style is crlf.
RETURN VALUES
Returns a single value which is a transcoder object.EXAMPLES
; Decodes a UTF-8-encoded string with ISO-8859-1.
; Note also how \r\n is read as a single newline.
(let* ((bv (string->utf8 "Döner\r\nkebab"))
(p (open-bytevector-input-port bv))
(tc (make-transcoder (latin-1-codec)
(eol-style lf)))
(tp (transcoded-port p tc)))
(get-string-all tp))
=> "Döner\nkebab"
APPLICATION USAGE
This procedure is used in applications that need to control the binary encoding of textual ports.RATIONALE
Transcoders let applications control parameters that would otherwise be implicit.COMPATIBILITY
Transcoders are unique to the R6RS I/O system.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.
SEE ALSO
transcoded-port(3scm), port-transcoder(3scm), native-transcoder(3scm), native-eol-style(3scm)STANDARDS
R6RSHISTORY
Port transcoders were introduced in R6RS.AUTHORS
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.BUGS
There is no transcoder? procedure in R6RS.| 2022-03-30 |