make-transcoder(3scm)

πŸ“¦ version 0-unstable-2024-02, in nixpkgs unstable

πŸ’… make-transcoder(3scm) β€” port transcoders, bestie ✨

okay so this is the make-transcoder(3scm) page from the Scheme Programmer's Manual, and it's literally all about port transcoders. no cap, every detail is staying. 🫢

🌸 NAME 🌸

  • make-transcoder
  • transcoder-codec
  • transcoder-eol-style
  • transcoder-error-handling-mode

…all serving port transcoders πŸ’–

πŸ“š LIBRARY πŸ“š

R6RS imports, exactly like this:

(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. main character energy, honestly.

  • codec β€” must be a codec. The standard codecs are those returned by latin-1-codec, utf-8-codec, and utf-16-codec.
  • eol-style β€” optional, and must be an eol-style(3scm) symbol: lf, cr, crlf, nel, crnel, or ls. It defaults to the native end-of-line style of the underlying platform.
  • handling-mode β€” 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. one value, one transcoder, slay ✨

πŸ’» EXAMPLES πŸ’»

this example is lowkey iconic:

       ; 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. giving you the aux cord, basically 🎧

πŸ¦‹ 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 πŸ‘€

⭐ STANDARDS ⭐

R6RS

πŸ•°οΈ HISTORY πŸ•°οΈ

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://github.com/schemedoc/manpages/.

πŸ™ˆ BUGS πŸ™ˆ

There is no transcoder? procedure in R6RS. not me looking for it either 😭


that's a wrap on the make-transcoder(3scm) page from the Scheme Programmer's Manual, dated 2022-03-30 πŸ’– mwah, byeee 🫢✨

πŸ“¦ where this page comes from