Skip to content

Commit

Permalink
fix file contents for non-ascii characters
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshuebner committed Aug 2, 2011
1 parent 38e9eef commit 2409b38
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/utils/utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -566,12 +566,18 @@ it is assumed that the string specifies the MIME type."
nconc (list key (eval value))))

#-allegro
(defun file-contents (pathname &key (element-type '(unsigned-byte 8)))
(with-open-file (s pathname :element-type element-type)
(let ((result
(make-array (file-length s) :element-type element-type)))
(read-sequence result s)
result)))
(defun file-contents (pathname &key (element-type '(unsigned-byte 8)) (external-format :utf-8))
(cond
((equal element-type '(unsigned-byte 8))
(with-open-file (s pathname :element-type element-type)
(let ((result
(make-array (file-length s) :element-type element-type)))
(read-sequence result s)
result)))
((equal element-type 'character)
(alexandria:read-file-into-string pathname :external-format external-format))
(t
(error "unsupported element type ~A for file-contents" element-type))))

(defun class-subclasses (class)
"Return a list of the names of all subclasses of a given class."
Expand Down

0 comments on commit 2409b38

Please sign in to comment.