anchor.diff:                     (ef external-format-of))
         stream
       (setf unread-index (iobuf-start ib))
  -    (let ((str nil)
  -          (ret nil))
  +    (let* ((str nil) (ret nil)
  +           (encoding (babel:external-format-encoding ef))
  +           (max-octets-per-char
  +            (babel-encodings:enc-max-units-per-char encoding)))
         (flet ((fill-buf-or-eof ()
                  (setf ret (%fill-ibuf read-fn fd ib))
                  (when (eq ret :eof)
  
positive.code:   (declare (ignore fd))
    (let* ((start-off (iobuf-start ib))
           (char-code (bref ib start-off)))
      (block nil
        (ecase (babel:external-format-eol-style ef)
          (:lf (when (= char-code (char-code #\Linefeed))
                 (incf (iobuf-start ib))
                 (return #\Newline)))
          (:cr (when (= char-code (char-code #\Return))
                 (incf (iobuf-start ib))
                 (return #\Newline)))
          (:crlf (when (= char-code (char-code #\Return))
                   (when (= (iobuf-length ib) 1)
                     (incf (iobuf-start ib))
                     (return :starvation))
                   (when (= (bref ib (1+ start-off))
                            (char-code #\Linefeed))
                     (incf (iobuf-start ib) 2)
                     (return #\Newline))))))))
  
  (defmethod stream-read-char-no-hang ((stream dual-channel-gray-stream))
    (with-accessors ((fd input-fd-of)
  
negative.code:                    (ib input-buffer-of)
                     (ef external-format-of))
        stream
      (let* ((str nil) (ret nil) (eof nil)
             (encoding (babel:external-format-encoding ef))
             (max-octets-per-char
              (babel-encodings:enc-max-units-per-char encoding)))
        ;; BUG: this comparision is probably buggy, FIXME.  A similar
        ;; bug was fixed in STREAM-READ-CHAR.  Must write a test for
        ;; this one first.
        (when (< (- (iobuf-size ib)
                    (iobuf-start ib))
                 max-octets-per-char)
          (iobuf-copy-data-to-start ib))
        (when (and (iomux:fd-ready-p fd :input)
                   (eq :eof (%fill-ibuf read-fn fd ib)))
          (setf eof t))
        (when (zerop (iobuf-length ib))
          (return* (if eof :eof nil)))
        ;; line-end handling
        (let ((line-end (maybe-find-line-ending-no-hang fd ib ef)))
          (cond ((eq :starvation line-end)
                 (return* (if eof #\Return nil)))
                ((characterp line-end)
                 (return* line-end))))
        ;; octet decoding
        (handler-case
            (setf (values str ret)
                  (foreign-string-to-lisp
                   (iobuf-data ib)
                   :offset (iobuf-start ib)
                   :count (iobuf-length ib)
                   :encoding encoding
                   :max-chars 1))
          (babel:end-of-input-in-character ()
            (return* nil)))
        (incf (iobuf-start ib) ret)
        (char str 0))))
  
  (defun %stream-unread-char (stream)
    (declare (type dual-channel-gray-stream stream))
  