string->bytevector(3scm)

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

okay so bestie, welcome to string->bytevector(3scm) from the Scheme Programmer's Manual β€” manual name folded in right here like a little name tag, periodt. πŸ’…βœ¨

🌸 NAME 🌸

string->bytevector β€” transcode a string to a bytevector. That's the whole assignment, and it ate. πŸ’–

πŸŽ€ LIBRARY πŸŽ€

Import it from either spot, depending on your vibe:

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

✨ SYNOPSIS ✨

(string->bytevector string transcoder)

πŸ’« DESCRIPTION πŸ’«

Returns the bytevector that results from transcoding string according to the output direction of transcoder. Like, you hand over the string and the transcoder, and the output side of that transcoder does its thing β€” that's the whole description, no cap. πŸ¦‹

🫢 RETURN VALUES 🫢

A single value comes back: a bytevector. One value, one bytevector, iconic. πŸ‘‘

🌈 EXAMPLES 🌈

Okay, example time, bestie:

(string->bytevector "Quux" (native-transcoder))
        => #vu8(81 117 117 120)

And this next one, verbatim:

string->bytevector "€"
                   (make-transcoder (latin-1-codec)
                                    (native-eol-style)
                                    (error-handling-mode raise)))
        => &i/o-encoding

🌸 APPLICATION USAGE 🌸

This procedure is a more general alternative to string->utf8(3scm). So if string->utf8(3scm) isn't the whole mood, this is the glow-up. πŸ’–

πŸ¦‹ COMPATIBILITY πŸ¦‹

This procedure is unique to R6RS. R6RS only, bestie β€” it's giving exclusive. ✨

πŸ’€ 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. 🚨
  • &i/o-encoding (R6RS) β€” a character was encountered that could not be translated into bytes, and transcoder's error-handling-mode is raise. 😭

πŸŽ€ SEE ALSO πŸŽ€

  • bytevector->string(3scm)
  • string->utf8(3scm)
  • open-transcoder(3scm)

⭐ STANDARDS ⭐

R6RS. That's the standard, periodt. πŸ’…

🧚 HISTORY 🧚

This procedure first appeared in R6RS as part of the redesigned I/O system. A little R6RS origin story, cute. 🌸

πŸ’œ 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/. 🫢


mwah πŸ’‹ β€” source/version sign-off: this page comes from the Scheme Programmer's Manual, dated 2022-05-14, and the page is string->bytevector(3scm). πŸŽ€βœ¨

πŸ“¦ where this page comes from