chickadee » srfi-207 » bytestring-substitute

bytestring-substitute bytevector alistprocedure

Each element of alist must be a pair of the form (x . y), where x and y are characters or bytes. Returns a newly allocated bytevector in which each occurrence of each x is replaced with y.

(Extension based on string-translate* from (chicken string)).

(bytestring-substitute #u8"Zaphod" '((#\d . #\z))) ⇒ #u8"Zaphoz"

(bytestring-translate #u8"gargleblaster" '((#\g . #\b) (#\e . #\o)))
 ⇒ #u8"barbloblastor"