Suppose I have a byte vector containing data encoded using, say, utf-8 (though I won't the name of the encoding until run time). How do I decode that into a string of characters?
One way is to use #'ext:write-byte-sequence
to output the data to a file and then turn around and open the file with :external-format charset:utf-8. But is there a way to do this without a scratch file?
EDIT 204-03-25 21:48:00 UTC
As required by ancient solemn custom, I hereby pay to sds
31.5.7. Converting between strings and byte vectors
Encodings can also be used to convert directly between strings and their corresponding byte vector representation according to that encoding.
(EXT:CONVERT-STRING-FROM-BYTES vector encoding &KEY :START :END)
converts the subsequence of vector (a (VECTOR (UNSIGNED-BYTE 8))
) from start to end to a STRING, according to the given encoding, and returns the resulting string.
(EXT:CONVERT-STRING-TO-BYTES string encoding &KEY :START :END)
converts the subsequence of string from start to end to a (VECTOR (UNSIGNED-BYTE 8))
, according to the given encoding, and returns the resulting byte vector.