From: Russell M. <rus...@ya...> - 2005-08-04 02:17:12
|
I'm attempting to write a subclass of sb-gray:fundamental-stream with the following properties: 1. at make-instance time you must supply :external-format. 2. one can read and write strings to/from it. 3. it transparently converts these strings into bytes for you with calls to the above functions, and directly calls unix-read and unix-write at the proper times. 4. it buffers input and output intelligently. 5. it supports read-n-bytes with the nifto-matic ability to not block if the requested number of bytes is not available. Given all of that, here is my question. Assume I've read some data from the network as bytes, and stored it into a (vector (unsigned-byte 8) *). To implement read-char, I need to call sb-ext:octets-to-string. But here I need to know how many bytes will make up a character, which I don't know how to figure out in general. From reading octets.lisp, I think that I can assume that 1 byte = 1 char at this time, but I know that this isn't right in general. I'm not very well read in the character encoding department, so any ideas you might have here would help. -russ |