anchor.diff:  
   (in-package #:com.schobadoo.bencode)
   
  -(defparameter +ascii+ (flex:make-external-format :ascii))
  -
   (defparameter +utf-8+ (flex:make-external-format :utf-8))
  -
  -(defvar *external-format* nil)
  -
  -(defun external-format (stream)
  -  (or *external-format*
  -      (flex:flexi-stream-external-format stream)))
   
   (define-condition unexpected-octet (error)
     ((expected-octet :initarg :expected-octet :reader expected-octet)
  
positive.code:             (error "Expected 0x~x got 0x~x" (char-code char) byte)))
      (continue () t)))
  
  (defun string-to-octets (string &optional (external-format +ascii+))
    (flex:string-to-octets string :external-format external-format))
  
  (defun octets-to-string (octets external-format)
    (flex:octets-to-string octets :external-format external-format))
  
  (defgeneric encode (object stream-or-symbol)
    (:documentation "Encode object and write it to stream or, if
  stream-or-symbol is a symbol, use an in-memory stream and return the
  resulting sequence.  "))
  
  (defmethod encode (object (external-format-keyword symbol))
    (let ((*external-format* (flex:make-external-format external-format-keyword)))
      (flex:with-output-to-sequence (stream)
        (encode object stream))))
  
  (defmethod encode ((list list) (stream flexi-stream))
    (write-byte (char-code #\l) stream)
    (dolist (x list)
      (encode x stream))
    (write-byte (char-code #\e) stream))
  
  (defmethod encode ((dictionary hash-table) (stream flexi-stream))
    (write-byte (char-code #\d) stream)
    (dolist (x (dictionary->alist dictionary))
      (destructuring-bind (k . v) x
  
negative.code:     (loop    ; Loop to allow restarting with several external formats 
        (restart-case
            (return ; Return to end loop when decoded without raising a condition
              (octets-to-string octets (flex:flexi-stream-external-format stream)))
          (use-binary ()
            :report "Use undecoded binary vector"
            (return octets))
          (set-external-format (external-format)
            :report "Set external format"
            :interactive (lambda ()
                           (format t "Enter a flexi-stream external format: ")
                           (multiple-value-list (eval (read))))
            (setf (flex:flexi-stream-external-format stream) external-format))))))
  
  (defun decode-list (stream)
    (must-read-char stream #\l)
  