* ew-dec.el (ew-decode-us-ascii): New function.
[elisp/flim.git] / ew-unit.el
index 74b379f..f706daf 100644 (file)
   (let ((len (length str)))
     (and
      (<= 3 len)
-     (string= (substring str 0 2) "=?")
-     (string= (substring str (- len 2) len) "?="))))
+     (eq (aref str 0) ?=)
+     (eq (aref str 1) ??)
+     (eq (aref str (- len 2)) ??)
+     (eq (aref str (1- len)) ?=))))
 
 (defun ew-decode-eword (str &optional eword-filter1 eword-filter2)
   (if (string-match ew-anchored-encoded-word-regexp str)
 (defalias 'ew-b-decode 'base64-decode-string)
 (defalias 'ew-q-decode 'q-encoding-decode-string)
 
-(defconst ew-charset-aliases
-  '((us-ascii . iso-8859-1)
-    (iso-2022-jp-2 . iso-2022-7bit-ss2)))
 (defun ew-char-decoder (charset)
-  (catch 'return 
-    (setq charset (downcase charset))
-    (let ((sym (intern charset))
-         tmp cs)
-      (when (setq tmp (assq sym ew-charset-aliases))
-       (setq sym (cdr tmp)))
-      (setq cs (intern (concat (symbol-name sym) "-unix")))
-      (when (coding-system-p cs)
-       (throw 'return
-              (closure-make (lambda (str) (decode-coding-string str cs)) cs)))
-      nil)))
+  (let ((sym (intern (downcase charset))))
+    (when (mime-charset-to-coding-system sym 'LF)
+      (closure-make
+       (lambda (str) (decode-mime-charset-string str sym 'LF))
+       sym))))