Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Bytevectors   [Contents][Index]


6.6.6.4 Converting Bytevectors to/from Integer Lists

Bytevector contents can readily be converted to/from lists of signed or unsigned integers:

(bytevector->sint-list (u8-list->bytevector (make-list 4 255))
                       (endianness little) 2)
⇒ (-1 -1)
Scheme Procedure: bytevector->u8-list bv
C Function: scm_bytevector_to_u8_list (bv)

Return a newly allocated list of unsigned 8-bit integers from the contents of bv.

Scheme Procedure: u8-list->bytevector lst
C Function: scm_u8_list_to_bytevector (lst)

Return a newly allocated bytevector consisting of the unsigned 8-bit integers listed in lst.

Scheme Procedure: bytevector->uint-list bv endianness size
C Function: scm_bytevector_to_uint_list (bv, endianness, size)

Return a list of unsigned integers of size bytes representing the contents of bv, decoded according to endianness.

Scheme Procedure: bytevector->sint-list bv endianness size
C Function: scm_bytevector_to_sint_list (bv, endianness, size)

Return a list of signed integers of size bytes representing the contents of bv, decoded according to endianness.

Scheme Procedure: uint-list->bytevector lst endianness size
C Function: scm_uint_list_to_bytevector (lst, endianness, size)

Return a new bytevector containing the unsigned integers listed in lst and encoded on size bytes according to endianness.

Scheme Procedure: sint-list->bytevector lst endianness size
C Function: scm_sint_list_to_bytevector (lst, endianness, size)

Return a new bytevector containing the signed integers listed in lst and encoded on size bytes according to endianness.