;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Revision: 0.6 $
+;; Version: $Revision: 0.12 $
;; Keywords: encoded-word, MIME, multilingual, header, mail, news
;; This file is part of SEMI (SEMI is Emacs MIME Interfaces).
(require 'mel)
(require 'std11)
(require 'mime-def)
-(require 'tl-list)
+(require 'cl)
+
+(defsubst find-non-ascii-charset-string (string)
+ "Return a list of charsets in the STRING except ascii."
+ (delq 'ascii (find-charset-string string))
+ )
+
+(defsubst find-non-ascii-charset-region (start end)
+ "Return a list of charsets except ascii in the region between START and END."
+ (delq 'ascii (find-charset-string (buffer-substring start end)))
+ )
;;; @ version
;;;
(defconst eword-encode-RCS-ID
- "$Id: eword-encode.el,v 0.6 1997-02-22 17:11:31 morioka Exp $")
+ "$Id: eword-encode.el,v 0.12 1997-03-01 04:09:16 tmorioka Exp $")
(defconst eword-encode-version (get-version-string eword-encode-RCS-ID))
(defvar eword-generate-X-Nsubject nil
"*If it is not nil, X-Nsubject field is generated
-when Subject field is encoded by `eword-encode-message-header'.")
+when Subject field is encoded by `eword-encode-header'.")
(defvar eword-charset-encoding-alist
'((us-ascii . nil)
(defun tm-eword::parse-lc-word (str)
(let* ((chr (sref str 0))
(lc (tm-eword::char-type chr))
- (i (char-length chr))
+ (i (char-bytes chr))
(len (length str))
)
(while (and (< i len)
(setq chr (sref str i))
(eq lc (tm-eword::char-type chr))
)
- (setq i (+ i (char-length chr)))
+ (setq i (+ i (char-bytes chr)))
)
(cons (cons lc (substring str 0 i)) (substring str i))
))
(str "") nstr)
(while (and (< p len)
(progn
- (setq np (+ p (char-length (sref string p))))
+ (setq np (+ p (char-bytes (sref string p))))
(setq nstr (substring string 0 np))
(setq ret (tm-eword::encoded-word-length
(cons nstr (cdr rword))
(if (and str (string-match eword-encoded-word-regexp str))
str)))
-(defun eword-encode-message-header (&optional code-conversion)
+(defun eword-encode-header (&optional code-conversion)
+ "Encode header fields to network representation, such as MIME encoded-word.
+
+It refer variable `eword-field-encoding-method-alist'."
(interactive "*")
(save-excursion
(save-restriction
(setq field-name (buffer-substring beg (1- (match-end 0))))
(setq end (std11-field-end))
(and (find-non-ascii-charset-region beg end)
- (let ((ret (or (ASSOC (downcase field-name)
- eword-field-encoding-method-alist
- :test (function
- (lambda (str1 str2)
- (and (stringp str2)
- (string= str1
- (downcase str2))
- ))))
+ (let ((ret (or (let ((fname (downcase field-name)))
+ (assoc-if
+ (function
+ (lambda (str)
+ (and (stringp str)
+ (string= fname (downcase str))
+ )))
+ eword-field-encoding-method-alist))
(assq t eword-field-encoding-method-alist)
)))
(if ret
(setq str
(encode-mime-charset-string
str
- (or (cdr (ASSOC
- "x-nsubject"
- eword-field-encoding-method-alist
- :test
+ (or (cdr (assoc-if
(function
- (lambda (str1 str2)
- (and (stringp str2)
- (string= str1
+ (lambda (str)
+ (and (stringp str)
+ (string= "x-nsubject"
(downcase str2))
- )))))
+ )))
+ eword-field-encoding-method-alist))
'iso-2022-jp-2)))
)
(insert (concat "\nX-Nsubject: " str))