On Wed, Jan 14, 2009 at 9:17 AM, Robert Dodier <robert.dodier@...> wrote:
> In some character encoding schemes there are byte sequences
> which don't encode any character. When those are encountered
> in input, SBCL triggers SB-INT:STREAM-DECODING-ERROR.
> Is there some way to tell SBCL to substitute a different character
> (e.g. #\?) or just eat the offending bytes? I searched the manual
> and the mailing list archives but I was unable to come up with
> I'd like to be able to modify the behavior of both already open
> streams (in particular console i/o) and the default behavior for
> any streams not yet open.
You need to provide a handler which provides the decoding to use with
the USE-VALUE restart.
(lambda (c) (use-value #\? c))))
(coerce '(102 111 111 98 97 114 240) '(array (unsigned-byte 8) 1))
In case of console IO you can do just the same, only you have to put
the handler somewhere around the function calls which do the reading
from the streams in question. (If performance matters you probably
don't want to stick it *immediately* around the call, but around
whatever loop is doing the reading.)
Relatedly, I added a new wishlist item: