cyrusharmon.org

Cyrus Harmon's new completely useless blog

 

Ok, I give up...

posted by cyrus in Lisp

I've given up trying to make SBCL take characters on byte streams. The spec is unclear as to what should happen here, and it would be really nice if we had a binary stream to which one could write-char, but since a reasonable interpretation (the one taken by the SBCL developers) is that this is a bad idea and shouldn't be allowed, I've decided to byte the bullet and look for other ways to solve the problem. There were two different places were the problem cropped up for me. First, I was trying to hand off the araneida stream to the cl-jpeg library which was trying to write-byte and write-sequence (of bytes) to this stream. This used to work and worked in OpenMCL, but didn't work in Unicode-enabled SBCL. Turns out, CLHS says this is a illegal. Ok, fair enough. So I figured I'd make the http stream a binary stream. This didn't work as araneida tries to read-char and write-char to the stream and the spec is unclear on how read-char and write-char from/to binary streams should be handled. So I figured I'd fix SBCL stream implementation to allow read-char and write-char for binary streams. This broke araneida's static file handler, which was checking the type of the stream, so disabled that and things were working fine. But, the problem is that isn't necessarily portable, character set issues aside. So I figured I'd try to make all of this work from a stock SBCL build.

Turns out the araneida things works, but in order to make the jpeg library work, I had to change the write-bytes to (write-char (code-char ...)) which seems to be working and similarly I had to change the write-sequence calls to loop over the sequence and write characters. Not the best solution, but probably better than the alternative. I'm still not sure what effect, if any, the environment variables LANG or LOCALE have on this, but things seem to be working for the moment.

Ok, I give up...