On Sun, 23 Jan 2011 22:52:36 -0500
Matthew Mondor <mm_li...@pulsar-zone.net> wrote:

> With ECL, the invalid sequence is already consumed when a more generic
> error occurs (I forgot which, but could check my CVS logs on request),
> which only allowed me to either ignore that invalid sequence or to
> substitute it to an invalid unicode character (0x241a or 0xfffd).  If
> the output must remain unmodified, there is no other way than to use
> bytes or 8-bit clean characters at the moment.  At least a year ago or
> more, we discussed this situation a bit on this list, yet I've not
> looked into it again since.  Perhaps this would be a good time to
> resume this work.

Attached is an example CUSTOM-READ-LINE showing the difference.
-- 
Matt
(defun custom-read-line (stream)
  (let ((line (make-array 512
                          :element-type 'character
                          :adjustable t
                          :fill-pointer 0)))
    (flet ((add-char (c)
             (declare (type character c))
             (unless (vector-push c line)
               (adjust-array line (* 2 (array-dimension line 0))
                             :element-type 'character)
               (vector-push c line)))
           (finalize-line ()
             (let ((len (length line)))
               (when (and (> len 0)
                          (char= #\Return (aref line (1- len))))
                 (vector-pop line)))
             line))
      (loop
         do
           (let ((c #+ecl(handler-case
                             (read-char stream)
                           (simple-error ()
                             #\UFFFD))
                    #+sbcl(handler-bind
                              ((sb-int:stream-decoding-error
                                #'(lambda (e)
                                    ;; Treat invalid UTF-8 octets as
                                    ;; ISO-8859 characters.
                                    (mapcar #'(lambda (c)
                                                (when (> c 127)
                                                  (add-char (code-char c))))
                                            
(sb-int:character-decoding-error-octets e))
                                    (invoke-restart 'sb-int:attempt-resync))))
                            (read-char stream))))
             (when (char= #\Newline c)
               (return (values (finalize-line) t)))
             (add-char c))))))
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Ecls-list mailing list
Ecls-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list

Reply via email to