|
@@ -157,9 +157,7 @@ a displaced array from STREAMs underlying vector. If it is == 7, then we have t
|
|
|
;;; Decode octets as an iso-8859-1 string (encoding == 0)
|
|
;;; Decode octets as an iso-8859-1 string (encoding == 0)
|
|
|
(defun stream-decode-iso-string (octets &key (start 0) (end (length octets)))
|
|
(defun stream-decode-iso-string (octets &key (start 0) (end (length octets)))
|
|
|
(declare #.utils:*standard-optimize-settings*)
|
|
(declare #.utils:*standard-optimize-settings*)
|
|
|
- #+CCL (ccl:decode-string-from-octets octets :start start :end end :external-format :iso-8859-1)
|
|
|
|
|
- #-CCL (flexi-streams:octets-to-string octets :start start :end end :external-format :iso-8859-1)
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ (flexi-streams:octets-to-string octets :start start :end end :external-format :iso-8859-1))
|
|
|
|
|
|
|
|
;;;
|
|
;;;
|
|
|
;;; XXX: Coded this way because I can't seem to get a simple :external-format :ucs-2 to work correctly
|
|
;;; XXX: Coded this way because I can't seem to get a simple :external-format :ucs-2 to work correctly
|
|
@@ -182,29 +180,25 @@ a displaced array from STREAMs underlying vector. If it is == 7, then we have t
|
|
|
(t
|
|
(t
|
|
|
;;
|
|
;;
|
|
|
;; else, we have a (hopefully) properly encoded string
|
|
;; else, we have a (hopefully) properly encoded string
|
|
|
|
|
+ (when (oddp end)
|
|
|
|
|
+ (warn-user "Malformed UCS string, length (~d) is odd---fixing by decrementing by 1" end)
|
|
|
|
|
+ (setf end (1- end)))
|
|
|
|
|
+
|
|
|
(let ((bom (get-byte-order-mark octets)))
|
|
(let ((bom (get-byte-order-mark octets)))
|
|
|
(ecase (the fixnum bom)
|
|
(ecase (the fixnum bom)
|
|
|
- (#xfffe #+CCL (ccl:decode-string-from-octets octets :start (+ 2 start) :end end :external-format :ucs-2le)
|
|
|
|
|
- #-CCL (flexi-streams:octets-to-string octets :start (+ 2 start) :end end :external-format :ucs-2le)
|
|
|
|
|
- )
|
|
|
|
|
- (#xfeff #+CCL (ccl:decode-string-from-octets octets :start (+ 2 start) :end end :external-format :ucs-2be)
|
|
|
|
|
- #-CCL (flexi-streams:octets-to-string octets :start (+ 2 start) :end end :external-format :ucs-2be)
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ (#xfffe (flexi-streams:octets-to-string octets :start (+ 2 start) :end end :external-format :ucs-2le))
|
|
|
|
|
+ (#xfeff (flexi-streams:octets-to-string octets :start (+ 2 start) :end end :external-format :ucs-2be))
|
|
|
(0 (make-string 0))))))))
|
|
(0 (make-string 0))))))))
|
|
|
|
|
|
|
|
(defun stream-decode-ucs-be-string (octets &key (start 0) (end (length octets)))
|
|
(defun stream-decode-ucs-be-string (octets &key (start 0) (end (length octets)))
|
|
|
"Decode octets as a UCS-BE string (encoding == 2)"
|
|
"Decode octets as a UCS-BE string (encoding == 2)"
|
|
|
(declare #.utils:*standard-optimize-settings*)
|
|
(declare #.utils:*standard-optimize-settings*)
|
|
|
- #+CCL (ccl:decode-string-from-octets octets :start start :end end :external-format :ucs-2be)
|
|
|
|
|
- #-CCL (flexi-streams:octets-to-string octets :start start :end end :external-format :ucs-2be)
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ (flexi-streams:octets-to-string octets :start start :end end :external-format :ucs-2be))
|
|
|
|
|
|
|
|
(defun stream-decode-utf-8-string (octets &key (start 0) (end (length octets)))
|
|
(defun stream-decode-utf-8-string (octets &key (start 0) (end (length octets)))
|
|
|
"Decode octets as a utf-8 string"
|
|
"Decode octets as a utf-8 string"
|
|
|
(declare #.utils:*standard-optimize-settings*)
|
|
(declare #.utils:*standard-optimize-settings*)
|
|
|
- #+CCL (ccl:decode-string-from-octets octets :start start :end end :external-format :utf-8)
|
|
|
|
|
- #-CCL (flexi-streams:octets-to-string octets :start start :end end :external-format :utf-8)
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ (flexi-streams:octets-to-string octets :start start :end end :external-format :utf-8))
|
|
|
|
|
|
|
|
(defun stream-decode-string (octets &key (start 0) (end (length octets)) (encoding 0))
|
|
(defun stream-decode-string (octets &key (start 0) (end (length octets)) (encoding 0))
|
|
|
"Decode octets depending on encoding"
|
|
"Decode octets depending on encoding"
|