1
0
Fork 0

- improved 'text:to-s', accepts byte or character vectors.

This commit is contained in:
cage 2022-02-17 16:04:26 +01:00
parent 75571fc2f5
commit 8da549e127
1 changed files with 11 additions and 1 deletions

View File

@ -78,7 +78,17 @@
object)
(defmethod to-s ((object vector))
(babel:octets-to-string object :errorp nil))
(handler-case
(let ((byte-vector (make-array (length object)
:element-type '(unsigned-byte 8)
:initial-element 0
:adjustable nil)))
(loop for i from 0 below (length object) do
(setf (aref byte-vector i)
(logand (aref object i) #xff)))
(babel:octets-to-string byte-vector :errorp nil))
(error ()
(coerce object 'string))))
(defmethod to-s ((object character))
(string object))