make-transcoder(3scm) Scheme Programmer's Manual make-transcoder(3scm)

make-transcoder, transcoder-codec, transcoder-eol-style, transcoder-error-handling-mode - port transcoders

(import (rnrs))                     ;R6RS
(import (rnrs io ports))            ;R6RS

(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)

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).

IronScheme
The native end-of-line style is crlf.

Returns a single value which is a transcoder object.

; 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"

This procedure is used in applications that need to control the binary encoding of textual ports.

Transcoders let applications control parameters that would otherwise be implicit.

Transcoders are unique to the R6RS I/O system.

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.

transcoded-port(3scm), port-transcoder(3scm), native-transcoder(3scm), native-eol-style(3scm)

R6RS

Port transcoders were introduced in R6RS.

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/.

There is no transcoder? procedure in R6RS.
2022-03-30