Comment 3 for bug 317409

Revision history for this message
Christophe Rhodes (csr21-cantab) wrote : Re: [Bug 317409] Re: wanted: use-value restart for decoding errors on streams

Nikodemus Siivola <email address hidden> writes:

> I'm assuming the stuff Christophe was working on is actually now in the
> tree.

I think so too. (I do have a branch in my local tree, but I think it
got merged and I just forgot to delete the branch. I'll try to check)

> This bug is still open, though, since in the current scheme on things
> one case set the replacement character once, but cannot handle
> individual ones or capture decoding errors in the first place.

Well, the documented interface is through :external-format, but since
it's implemented in terms of handlers and restarts (if I remember
correctly) programmatically doing stuff should be possible too.
Something like
  (defun smart-replacement-function (c)
    (let ((char (code-char (character-encoding-error-code c)))
          (xf (character-coding-error-external-format c)))
      (magic char xf)))
  (handler-bind ((encoding-error #'smart-replacement-function))
    ...)
should already be possible, modulo exported symbols (and lack of MAGIC :-)

> Adding this doesn't look hard in the current scheme of things, though.

Making magic available per-stream might involve a little bit of work.
Can't really remember :-/

Cheers,

Christophe