1998-08-21 Tanaka Akira <akr@jaist.ac.jp>
+ * ew-dec.el (ew-decode-us-ascii): New function.
+ (ew-decode-none): Use the function `ew-decode-us-ascii' instead of
+ the variable `ew-decode-us-ascii'.
+ (ew-decode-generic): Ditto.
+ (ew-decode-generic-others): Ditto.
+
+ * ew-unit.el (ew-charset-aliases): Abolished.
+ (ew-char-decoder): Use `decode-mime-charset-string' with 'LF as lbt.
+
+ * ew-var.el (ew-decode-us-ascii): Abolished.
+ (ew-default-mime-charset): New variable.
+ (ew-dynamic-options): Add `ew-default-mime-charset'.
+
+1998-08-21 Tanaka Akira <akr@jaist.ac.jp>
+
* ew-unit.el (ew-eword-p): Use aref instead of substring.
(ew-char-decoder): Refined.
(when (< 0 ew-parse-error-sit-for-seconds)
(sit-for ew-parse-error-sit-for-seconds))))))
+(defun ew-decode-us-ascii (str)
+ (decode-mime-charset-string str ew-default-mime-charset 'LF))
+
(defun ew-decode-none (anchor frag end eword-filter)
(while (not (eq frag end))
- (put frag 'decoded (funcall ew-decode-us-ascii (symbol-name frag)))
+ (put frag 'decoded (ew-decode-us-ascii (symbol-name frag)))
(setq frag (get frag 'next-frag))))
(defun ew-decode-generic (anchor start end
((memq type puncts)
(when buff
(setq buff (nreverse buff)
- tmp (funcall ew-decode-us-ascii
- (mapconcat 'car buff "")))
+ tmp (ew-decode-us-ascii
+ (mapconcat 'car buff "")))
(if (ew-contain-non-ascii-p tmp)
(setq result (ew-rcons* result tmp))
(setq result (ew-rcons*
result
- (funcall ew-decode-us-ascii
- (mapconcat 'cdr buff "")))))
+ (ew-decode-us-ascii
+ (mapconcat 'cdr buff "")))))
(setq buff ()))
(setq result (ew-rcons*
result
(error "something wrong: unexpected token: %s (%s)" frag type))))
(when buff
(setq buff (nreverse buff)
- tmp (funcall ew-decode-us-ascii
- (mapconcat 'car buff "")))
+ tmp (ew-decode-us-ascii
+ (mapconcat 'car buff "")))
(if (ew-contain-non-ascii-p tmp)
(setq result (ew-rcons* result tmp))
(setq result (ew-rcons*
result
- (funcall ew-decode-us-ascii
- (mapconcat 'cdr buff "")))))
+ (ew-decode-us-ascii
+ (mapconcat 'cdr buff "")))))
(setq buff ()))
(nreverse result)))
result
(symbol-name (car frags)))
frags (cdr frags)))
- (list (funcall ew-decode-us-ascii
- (apply 'concat (nreverse result))))))
+ (list (ew-decode-us-ascii
+ (apply 'concat (nreverse result))))))
(defun ew-decode-unstructured (anchor start end eword-filter)
(ew-decode-generic
(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)
- (x-ctext . ctext)
- ))
-
(defun ew-char-decoder (charset)
- (let ((sym (intern (downcase 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)
+ (let ((sym (intern (downcase charset))))
+ (when (mime-charset-to-coding-system sym 'LF)
(closure-make
- (lambda (str) (decode-coding-string str cs))
- cs))))
+ (lambda (str) (decode-mime-charset-string str sym 'LF))
+ sym))))
(defvar ew-ignore-76bytes-limit nil)
(defvar ew-permit-sticked-comment nil)
(defvar ew-permit-sticked-special nil)
-
-(defvar ew-parse-error-sit-for-seconds 0)
-
-;;; anonymous function to decode ground string.
-;; NOTE: STR is CRLF-form and it should return as CRLF-form.
-(defvar ew-decode-us-ascii (lambda (str) (decode-coding-string str 'iso-latin-1-unix)))
+(defvar ew-default-mime-charset 'x-ctext)
;;;
(defvar ew-decode-field-syntax-alist
(defvar ew-decode-field-default-syntax '(ew-scan-unibyte-unstructured))
+(defvar ew-parse-error-sit-for-seconds 0)
+
;;; constants.
(defconst ew-token-regexp "[-!#-'*+0-9A-Z^-~]+")
;;; utilities for variables.
(defun ew-dynamic-options ()
- (logior
- (if ew-decode-sticked-encoded-word 1 0)
- (if ew-decode-quoted-encoded-word 2 0)
- (if ew-ignore-75bytes-limit 4 0)
- (if ew-ignore-76bytes-limit 8 0)
- (if ew-permit-sticked-comment 16 0)
- (if ew-permit-sticked-special 32 0)))
+ (cons
+ ew-default-mime-charset
+ (logior
+ (if ew-decode-sticked-encoded-word 1 0)
+ (if ew-decode-quoted-encoded-word 2 0)
+ (if ew-ignore-75bytes-limit 4 0)
+ (if ew-ignore-76bytes-limit 8 0)
+ (if ew-permit-sticked-comment 16 0)
+ (if ew-permit-sticked-special 32 0))))