Scheme Programmer's Manual

NAME

bytevector->u8-list, bytevector->sint-list, bytevector->uint-list - convert a bytevector to a list of integers

LIBRARY

(import (rnrs))                     ;R6RS
(import (rnrs bytevectors))         ;R6RS

SYNOPSIS

(bytevector->u8-list bytevector)
(bytevector->sint-list bytevector endianness size)
(bytevector->uint-list bytevector endianness size)

DESCRIPTION

These procedures convert a bytevector to a list of integer objects according to size and endianness. The integers have the same order as the data in bytevector.

The bytevector->u8-list procedure is the same as bytevector->uint-list with a size of 1. It returns a newly allocated list of the octets of bytevector in the same order.

RETURN VALUES

Returns a newly allocated list of exact integer objects.

EXAMPLES

(let ((b (make-bytevector 4 -127)))
  (bytevector->u8-list b))
          => #vu8(129 129 129 129)

(let ([b (u8-list->bytevector
           '(#x1 #x2 #x3 #xFF #x1 #x2 #x1 #x2))])
  (bytevector->sint-list b (endianness little) #x2))
          => (#x201 #x-FD #x201 #x201)

(let ([b (u8-list->bytevector
           '(#x1 #x2 #x3 #xFF #x1 #x2 #x1 #x2))])
  (bytevector->uint-list b (endianness little) #x2))
          => (#x201 #xFF03 #x201 #x201)

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. In particular, size must be a positive exact integer object and bytevector must be evenly divisible by size.

SEE ALSO

endianness(7), u8-list->bytevector(3)

STANDARDS

R6RS

AUTHORS

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at

Index

NAME
LIBRARY
SYNOPSIS
DESCRIPTION
RETURN VALUES
EXAMPLES
ERRORS
SEE ALSO
STANDARDS
AUTHORS
Return to Main Contents