bytevector-utils

  1. bytevector-utils
  2. Documentation
    1. Bytevector Utils
      1. Usage
      2. bytevector-u8-set!
      3. bytevector-s8-set!
      4. bytevector-u16-set!
      5. bytevector-s16-set!
      6. bytevector-u32-set!
      7. bytevector-s32-set!
      8. bytevector-u64-set!
      9. bytevector-s64-set!
    2. Bytevector Set Int
      1. Usage
      2. bytevector-set-u8!
      3. bytevector-set-u16-le!
      4. bytevector-set-u16-be!
      5. bytevector-set-u32-le!
      6. bytevector-set-u32-be!
      7. bytevector-set-u64-le!
      8. bytevector-set-u64-be!
      9. *bytevector-set-u8!
      10. *bytevector-set-u16-le!
      11. *bytevector-set-u16-be!
      12. *bytevector-set-u32-le!
      13. *bytevector-set-u32-be!
      14. *bytevector-set-u64-le!
      15. *bytevector-set-u64-be!
    3. Pack Integer
      1. Usage
      2. pack-u8
      3. pack-u16
      4. pack-u32
      5. pack-u64
      6. pack-integer
  3. Notes
  4. Requirements
  5. Author
  6. Repository
  7. Version history
  8. License

Documentation

Bytevector Utils

BV
(or bytevector srfi-4-vector)
IDX
fixnum ; {(<= 0 ...)}

Usage

(import bytevector-utils)

bytevector-u8-set!

bytevector-s8-set!

[procedure] (bytevector-u8-set! BV IDX UINT)
[procedure] (bytevector-s8-set! BV IDX INT)
UINT
fixnum ; 0..(2^8)-1
INT
fixnum ; -(2^7)..(2^7)-1

bytevector-u16-set!

bytevector-s16-set!

[procedure] (bytevector-u16-set! BV IDX UINT [ORDER])
[procedure] (bytevector-s16-set! BV IDX INT [ORDER])
UINT
fixnum ; 0..(2^16)-1
INT
fixnum ; -(2^15)..(2^15)-1

bytevector-u32-set!

bytevector-s32-set!

[procedure] (bytevector-u32-set! BV IDX UINT [ORDER])
[procedure] (bytevector-s32-set! BV IDX INT [ORDER])
UINT
number ; 0..(2^32)-1
INT
number ; -(2^31)..(2^31)-1

bytevector-u64-set!

bytevector-s64-set!

[procedure] (bytevector-u64-set! BV IDX UINT [ORDER])
[procedure] (bytevector-s64-set! BV IDX INT [ORDER])
UINT
number ; 0..(2^64)-1
INT
number ; -(2^63)..(2^63)-1

Bytevector Set Int

Stuff integers into a bytevector.

Usage

(import bytevector-set-int)

bytevector-set-u8!

[procedure] (bytevector-set-u8! BV N [(OFFSET 0)])

Sets the byte at OFFSET to N in BV.

bytevector-set-u16-le!

[procedure] (bytevector-set-u16-le! BV N [(OFFSET 0)])

Sets the 2 bytes at OFFSET to N in BV using little-endian byte order.

bytevector-set-u16-be!

[procedure] (bytevector-set-u16-be! BV N [(OFFSET 0)])

Sets the 2 bytes at OFFSET to N in BV using big-endian byte order.

bytevector-set-u32-le!

[procedure] (bytevector-set-u32-le! BV N [(OFFSET 0)])

Sets the 4 bytes at OFFSET to N in BV using little-endian byte order.

bytevector-set-u32-be!

[procedure] (bytevector-set-u32-be! BV N [(OFFSET 0)])

Sets the 4 bytes at OFFSET to N in BV using big-endian byte order.

bytevector-set-u64-le!

[procedure] (bytevector-set-u64-le! BV N [(OFFSET 0)])

Sets the 8 bytes at OFFSET to N in BV using little-endian byte order.

bytevector-set-u64-be!

[procedure] (bytevector-set-u64-be! BV N [(OFFSET 0)])

Sets the 8 bytes at OFFSET to N in BV using big-endian byte order.

*bytevector-set-u8!

[procedure] (*bytevector-set-u8! BV N OFFSET)

Sets the byte at OFFSET to N in BV.

Performs no argument checking.

*bytevector-set-u16-le!

[procedure] (*bytevector-set-u16-le! BV N OFFSET)

Sets the 2 bytes at OFFSET to N in BV using little-endian byte order.

Performs no argument checking.

*bytevector-set-u16-be!

[procedure] (*bytevector-set-u16-be! BV N OFFSET)

Sets the 2 bytes at OFFSET to N in BV using big-endian byte order.

Performs no argument checking.

*bytevector-set-u32-le!

[procedure] (*bytevector-set-u32-le! BV N OFFSET)

Sets the 4 bytes at OFFSET to N in BV using little-endian byte order.

Performs no argument checking.

*bytevector-set-u32-be!

[procedure] (*bytevector-set-u32-be! BV N OFFSET)

Sets the 4 bytes at OFFSET to N in BV using big-endian byte order.

Performs no argument checking.

*bytevector-set-u64-le!

[procedure] (*bytevector-set-u64-le! BV N OFFSET)

Sets the 8 bytes at OFFSET to N in BV using little-endian byte order.

Performs no argument checking.

*bytevector-set-u64-be!

[procedure] (*bytevector-set-u64-be! BV N OFFSET)

Sets the 8 bytes at OFFSET to N in BV using big-endian byte order.

Performs no argument checking.

Pack Integer

Set integer in bytevector.

KIND
(or symbol bytevector pointer) ; symbol from (bytevector pointer)
START
fixnum ; (<= 0 ...)
ORDER
symbol ; big-endian be big little-endian le little

The pack functions are pure or mutating depending on the KIND.

Usage

(import pack-integer)

pack-u8

[procedure] (pack-u8 N [kind: KIND] [start: START]) -> PACK

Returns the number N packed into an object of KIND, at position START.

pack-u16

[procedure] (pack-u16 N [kind: KIND] [start: START] [order: ORDER]) -> PACK

Returns the number N packed into an object of KIND, at position START.

pack-u32

[procedure] (pack-u32 N [kind: KIND] [start: START] [order: ORDER]) -> PACK

Returns the number N packed into an object of KIND, at position START.

pack-u64

[procedure] (pack-u64 N [kind: KIND] [start: START] [order: ORDER]) -> PACK

Returns the number N packed into an object of KIND, at position START.

pack-integer

[procedure] (pack-integer N [kind: KIND] [start: START] [order: ORDER]) -> PACK

Returns the number N packed into an object of KIND, at position START.

Notes

Requirements

string-utils check-errors

test

Author

Kon Lovett

Repository

This egg is hosted on the CHICKEN Subversion repository:

https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/blob-utils

If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.

Version history

1.0.1
Fix signatures.
1.0.0
CHICKEN 6 release.

License

Copyright (C) 2026 Kon Lovett. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.