Commit 1d279311 authored by kilian.sprotte's avatar kilian.sprotte
Browse files

read-utf-8-string: avoiding NIL fixnum, utf-8-bytes-to-string: (make-string...

read-utf-8-string: avoiding NIL fixnum, utf-8-bytes-to-string: (make-string ... :element-type 'character)

darcs-hash:92b65be28c0ad2df8462af645473be6d8c3b491d
parent 2ea29792
Loading
Loading
Loading
Loading
+24 −24
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ extract the character starting at the given start position."
the string it encodes." 
 (declare (type (array (unsigned-byte 8)) bytes)
           #.*optimize*)
  (loop :with buffer = (make-string (utf-8-string-length bytes))
  (loop :with buffer = (make-string (utf-8-string-length bytes) :element-type 'character)
        :with array-position = 0
        :with string-position = 0
        :with array-length = (length bytes)
@@ -172,7 +172,7 @@ the string it encodes."
        :finally (return buffer)))

(defun read-utf-8-string (input &key null-terminated stop-at-eof
                          char-length byte-length)
                          (char-length -1) (byte-length -1))
  "Read utf-8 encoded data from a byte stream and construct a
string with the characters found. When null-terminated is given
it will stop reading at a null character, stop-at-eof tells it to
@@ -187,8 +187,8 @@ max amount of characters or bytes to read."
        (string (make-array 64 :element-type 'character
                            :adjustable t :fill-pointer 0)))
    (loop
      (when (or (and byte-length (>= bytes-read byte-length))
                (and char-length (= char-length (length string))))
       (when (or (and (/= -1 byte-length) (>= bytes-read byte-length))
		 (and (/= -1 char-length) (= char-length (length string))))
	 (return))
       (let ((next-char (read-byte input (not stop-at-eof) :eof)))
	 (when (or (eq next-char :eof)