Next: , Previous: , Up: SRFI-207 String-notated bytevectors   [Contents][Index]


7.5.49.3 Conversion

Scheme Procedure: bytevector->hex-string bytevector
Scheme Procedure: hex-string->bytevecto string

Converts between a bytevector and a string containing pairs of hexadecimal digits. If string is not pairs of hexadecimal digits, an error satisfying bytestring-error? is raised

(bytevector->hex-string #u8"Ford")"467f7264"
(hex-string->bytevector "5a6170686f64")#u8"Zaphod")
Scheme Procedure: bytevector->base64 bytevector [digits]
Scheme Procedure: base64->bytevecto string [digits]

Converts between a bytevector and its base-64 encoding as a string. The 64 digits are represented by the characters 0-9, A-Z, a-z, and the symbols + and /. However, there are different variants of base-64 encoding which use different representations of the 62nd and 63rd digit. If the optional argument digits (a two-character string) is provided, those two characters will be used as the 62nd and 63rd digit instead. Details can be found in RFC 4648.

If string is not in base-64 format, an error satisfying bytestring-error? is raised. However, characters that satisfy char-whitespace? are silently ignored.

(bytevector->base64 #u8(1 2 3 4 5 6)) ⇒ ⇒ "AQIDBAUG"
(bytevector->base64 #u8"Arthur Dent")"QXJ0aHVyIERlbnQ="
(base64->bytevector "+/     /+")#u8(#xfb #xff #xfe)
Scheme Procedure: bytestring->list bytevector [start [end]]

Converts all or part of a bytevector into a list of the same length containing characters for elements in the range 32 to 127 and exact integers for all other elements.</p>

(bytestring->list #u8(#x41 #x42 1 2) 1 3)(#\B 1)
Scheme Procedure: make-bytestring-generator arg …

Returns a generator that when invoked will return consecutive bytes of the bytevector that bytestring would create when applied to args, but without creating any bytevectors. The args are validated before any bytes are generated; if they are ill-formed, an error satisfying bytestring-error? is raised.

(generator->list (make-bytestring-generator "lorem"))(#x6c #x6f #x72 #x65 #x6d)

Next: Selection, Previous: Constructors, Up: SRFI-207 String-notated bytevectors   [Contents][Index]