string->bytevector(3scm) Scheme Programmer's Manual string->bytevector(3scm)

string->bytevector - transcode a string to a bytevector

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

(string->bytevector string transcoder)

Returns the bytevector that results from transcoding string according to the output direction of transcoder.

Returns a single value; a bytevector.

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

This procedure is a more general alternative to string->utf8(3scm).

This procedure is unique to R6RS.

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.

bytevector->string(3scm), string->utf8(3scm), make-transcoder(3scm)

R6RS

This procedure first appeared in R6RS as part of the redesigned I/O system.

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

2022-05-14