Commit 0bf8b8a8 authored by Zach Beane's avatar Zach Beane
Browse files

Consistently save and apply the stream-external-format to streams, sockets.

Should fix issue #3.
parent 4d6a6552
......@@ -8,6 +8,7 @@
(defparameter *external-format-translations*
'((:octets . :latin1)
(:latin1-base . :latin1)
(:utf-8 . :utf-8)
(nil . :latin1)))
(defun translate-external-format (external-format)
......@@ -183,8 +184,7 @@ values otherwise."
(defun excl:find-external-format (name &key errorp)
(declare (ignore errorp))
(declare (ignore name))
(translate-external-format name))
(defun excl:crlf-base-ef (external-format)
......@@ -364,7 +364,7 @@ values otherwise."
:initarg :external-format
:initform :default
:initform :latin1
:accessor zacl-cl:stream-external-format)))
(defmethod shared-initialize :after ((stream
......@@ -399,7 +399,8 @@ values otherwise."
(defmethod stream-write-string ((stream excl:single-channel-simple-stream) string &optional start end)
(unless start (setf start 0))
(unless end (setf end (length string)))
(let ((buffer (string-to-octets string :start start :end end)))
(let ((buffer (string-to-octets string :start start :end end
:external-format (zacl-cl:stream-external-format stream))))
(excl:device-write stream buffer 0 (length buffer) nil)))
(defmethod stream-write-sequence ((stream excl:single-channel-simple-stream) sequence start end &key &allow-other-keys)
......@@ -35,7 +35,12 @@
:initarg :bytes-written
:initform 0
:accessor bytes-written)))
:accessor bytes-written)
:initarg :external-format
:initform :latin-1
:reader socket-ef
:accessor zacl-cl:stream-external-format)))
(defmethod stream-write-byte :after ((stream zacl-socket) byte)
(declare (ignore byte))
......@@ -47,7 +52,7 @@
(defmethod stream-write-char ((stream zacl-socket) char)
(map nil (lambda (octet)
(stream-write-byte stream octet))
(string-to-octets (string char))))
(string-to-octets (string char) :external-format (socket-ef stream))))
(defmethod stream-write-sequence :after ((stream zacl-socket) sequence
start end &key &allow-other-keys)
......@@ -63,7 +68,8 @@
(defmethod stream-write-sequence ((stream zacl-socket) sequence start end
&key &allow-other-keys)
(when (typep sequence 'string)
(setf sequence (string-to-octets sequence :start start :end end))
(setf sequence (string-to-octets sequence :start start :end end
:external-format (socket-ef stream)))
(setf start 0)
(setf end (length sequence)))
(write-sequence sequence (real-stream stream) :start start :end end))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment