From: Pascal J. Bourguignon on 16 Jul 2010 17:12 pjb(a)informatimago.com (Pascal J. Bourguignon) writes: > "ansofive(a)gmail.com" <ansofive(a)gmail.com> writes: > >> Hi, >> >> I've been playing around with this and I've discovered that listen >> seems to only work with character streams. I've only tried it on >> clisp at this point but it wouldn't suprise me if it was the same on >> sbcl. The HyperSpec says "Returns true if there is a character >> immediately available ... listen is intended to be used when input- >> stream obtains characters from an interactive device such as a >> keyboard. " which seems to suggest that listen wants a character >> stream. > > Oops, I forgot that. > > >> Is there character encoding that allows be to read 8-bit characters? >> Hmmmm..... Seems to me I remember something from Practical Common >> Lisp...... > > Yes, you can use charset:iso-8859-1 or any of the other iso-8859-* charsets. However, you may still have difficulties, if it's a binary stream, because clisp processes character streams, in particular CR, CR-LF and LF sequences are converted to #\newline. I don't know a way to disable that. -- __Pascal Bourguignon__ http://www.informatimago.com/
From: Dennis Dunn on 17 Jul 2010 07:11 Hi Pascal, On 7/16/2010 5:12 PM, Pascal J. Bourguignon wrote: >> Yes, you can use charset:iso-8859-1 or any of the other iso-8859-* charsets. Thanks for the hint, I'll try it out today. Dennis
From: ansofive on 19 Jul 2010 20:21 Success! In my googling I ran across the ext package in clisp - a quick review of loop and it's working. :) #+clisp (defun read-packet (stream) "Read a packet from the stream." (let ((buffer (loop for b = (read-byte stream) then (ext:read-byte-no-hang stream nil :eof) until (not b) collect b ))) (make-array (length buffer) :element-type '(unsigned-byte 8) :initial-contents buffer))) Thanks again. Dennis
From: Pascal Costanza on 20 Jul 2010 03:11 On 20/07/2010 02:21, ansofive(a)gmail.com wrote: > Success! > > In my googling I ran across the ext package in clisp - a quick review > of loop and it's working. :) > > #+clisp > (defun read-packet (stream) > "Read a packet from the stream." > (let ((buffer > (loop for b = (read-byte stream) > then (ext:read-byte-no-hang stream nil :eof) > until (not b) > collect b ))) > (make-array (length buffer) :element-type '(unsigned-byte > 8) :initial-contents buffer))) > > Thanks again. Instead of (make-array (length bla) :element-type '(unsigned-byte 8) :initial-contents bla) you can also say (coerce bla '(vector (unsigned-byte 8))) which has a chance to be a bit more efficient. Pascal -- My website: http://p-cos.net Common Lisp Document Repository: http://cdr.eurolisp.org Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Pascal J. Bourguignon on 20 Jul 2010 03:21 Pascal Costanza <pc(a)p-cos.net> writes: > On 20/07/2010 02:21, ansofive(a)gmail.com wrote: >> Success! >> >> In my googling I ran across the ext package in clisp - a quick review >> of loop and it's working. :) >> >> #+clisp >> (defun read-packet (stream) >> "Read a packet from the stream." >> (let ((buffer >> (loop for b = (read-byte stream) >> then (ext:read-byte-no-hang stream nil :eof) >> until (not b) >> collect b ))) >> (make-array (length buffer) :element-type '(unsigned-byte >> 8) :initial-contents buffer))) >> >> Thanks again. > > Instead of > > (make-array (length bla) > :element-type '(unsigned-byte 8) > :initial-contents bla) > > you can also say > > (coerce bla '(vector (unsigned-byte 8))) > > which has a chance to be a bit more efficient. It would be a sad implementation, if it made any difference. -- __Pascal Bourguignon__ http://www.informatimago.com/
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: sound compression / backward-adaptive linear prediction Next: Portable Lisp |