Changeset 3380

Show
Ignore:
Timestamp:
06/30/08 11:53:00 (6 months ago)
Author:
hans
Message:

Be more tolerant when string can't be decoded as UTF-8. We now fall
back to ASCII and warn.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bknr/datastore/src/data/encoding.lisp

    r2814 r3380  
    339339  (labels ((octets-to-string-safe (octets) ; safe and portable 
    340340             (let ((flexi-streams:*substitution-char* #\?)) 
    341                (flexi-streams:octets-to-string octets :external-format #.(flexi-streams:make-external-format :utf-8)))) 
     341               (handler-case 
     342                   (flexi-streams:octets-to-string octets :external-format :utf-8) 
     343                 (flexi-streams:external-format-condition (e) 
     344                   (declare (ignore e)) 
     345                   (let ((string (flexi-streams:octets-to-string octets :external-format :ascii))) 
     346                     (warn "could not decode string ~S as utf-8, decoded as ASCII" string) 
     347                     string))))) 
    342348           (octets-to-string (octets) 
    343349             (handler-case