title: How to convert byte array to string in Common Lisp?
body: <p>I'm calling a funny API that returns a byte array, but I want a text stream.  Is there an easy way to get a text stream from a byte array?  For now I just threw together:</p>
  
  <pre><code>(defun bytearray-to-string (bytes)
    (let ((str (make-string (length bytes))))
      (loop for byte across bytes
         for i from 0
         do (setf (aref str i) (code-char byte)))
      str))
  </code></pre>
  
  <p>and then wrap the result in with-input-from-string, but that can't be the best way.  (Plus, it's horribly inefficient.)</p>
  
  <p>In this case, I know it's always ASCII, so interpreting it as either ASCII or UTF-8 would be fine.  I'm using Unicode-aware SBCL, but I'd prefer a portable (even ASCII-only) solution to a SBCL-Unicode-specific one.</p>