Skip to content

Selection ​

Scheme Procedure: bytestring-pad bytevector len char-or-u8 ​

Scheme Procedure: bytestring-pad-right bytevector len char-or-u8 ​

Returns a newly allocated bytevector with the contents of bytevector plus sufficient additional bytes at the beginning/end containing char-or-u8 (which can be either an ASCII character or an exact integer in the range 0-255) such that the length of the result is at least len.

emacs-lisp
(bytestring-pad #u8"Zaphod" 10 #\_) ⇒ #u8"____Zaphod"
(bytestring-pad-right #u8(#x80 #x7f) 8 0) ⇒ #u8(#x80 #x7f 0 0 0 0 0 0)

Scheme Procedure: bytestring-trim bytevector pred ​

Scheme Procedure: bytestring-trim-right bytevector pred ​

Scheme Procedure: bytestring-trim-both bytevector pred ​

Returns a newly allocated bytevector with the contents of bytevector, except that consecutive bytes at the beginning / the end / both the beginning and the end that satisfy pred are not included.

emacs-lisp
(bytestring-trim #u8"   Trillian" (lambda (b) (= b #x20)))
⇒ #u8"Trillian"
(bytestring-trim-both #u8(0 0 #x80 #x7f 0 0 0) zero?) ⇒ #u8(#x80 #x7f)