Question

I've some data that I'm reading in using read-line and I want to convert it into a byte-array. babel:string-to-octet works for the most part except when the character\byte is larger (above 200) in which case it returns two numbers. As an example, if the character is ú using babel:string-to-octet returns (195 185) instead of 250 which is what I'm looking for. I tried a number of encodings in babel but none of them seem to work.

If I use read-byte or read-sequence it does read in 250. But for reasons of backward compatibility, I'm left with using read-line and I would like to know if there is something I'm missing when using babel:string-to-octet to convert ú to 250.

I'm using ccl 1.8 btw.

No correct solution

OTHER TIPS

There are more than 256 characters supported by most common-lisp implementations. By the pigeonhole principle, that means you can't convert all characters to a single byte.

If you just want to convert the lisp internal character codes 0-255 to bytes, than char-code will do what you want. However, the result will be implementation defined, as implementations are not required to use any particular encoding internally.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top