chickadee » srfi-207 » bytestring-translate

bytestring-translate bytevector from toprocedure

from and to may be bytes (exact integers), ASCII characters, or lists of bytes/characters. to must contain at least as many elements as from.

Translates each occurrence of from to to in bytevector, returning a newly allocated bytevector. If from and to are lists, then the ith element of from is replaced with the ith element of to.

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

(bytestring-translate #u8"Zaphod" #\d #\z) ⇒ #u8"Zaphoz"

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