Author: mhenoch Date: Thu Aug 31 18:48:17 2006 New Revision: 36 Modified: cl-darcs/trunk/util.lisp Log: Add string-to-bytes, and explaining comment Modified: cl-darcs/trunk/util.lisp ============================================================================== --- cl-darcs/trunk/util.lisp (original) +++ cl-darcs/trunk/util.lisp Thu Aug 31 18:48:17 2006 @@ -63,10 +63,16 @@ (atom (lambda (c) (eql c delimiters))) (list (lambda (c) (member c delimiters))))) +;; These two functions should be eachother's inverses, and be defined +;; for all possible 8-bit values. (defun bytes-to-string (sequence) "Convert SEQUENCE, a sequence of binary values, to a string." (map 'string #'code-char sequence)) +(defun string-to-bytes (string) + "Convert STRING to a vector of (unsigned-byte 8)." + (map '(vector (unsigned-byte 8)) #'char-code string)) + ;; These functions read vaguely character-like data from binary ;; streams.