I have a list of bytes that I want to read as a string. I tried, for example,
(sb-ext:octets-to-string (list 30 40 50))
or
(babel:octets-to-string (list 30 40 50))
but both complain that the input is not "(VECTOR (UNSIGNED-BYTE 8))". So I learned that I can convert my list to a vector via
(coerce (list 30 40 50) 'vector)
but that is still not enough, because coerce returns a "simple-vector" and the elements are still in integer, not "(unsigned-byte 8)".
I looked at the similar questions, but none of them deal with the input being a list of integers. Note that I know that no integer is larger than 255, so overflow is not an issue.
You need to create a vector with an element type
(unsigned-byte 8). Vectors can, for example, be created viaMAKE-ARRAYandCOERCE.MAKE-ARRAYneeds the correct element type:COERCEneeds the correct type to coerce to. The type descriptionVECTORtakes an element type as the second element: