[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: Detect coding system with priority (was: 文字化け )



>>>>> In [emacs-w3m : No.01618]
>>>>>	TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp> wrote:

土屋さん> (with-temp-buffer
土屋さん>   (set-buffer-multibyte nil)
土屋さん>   (insert-file-contents-as-binary w3m-bookmark-file)
土屋さん>   (w3m-detect-coding-region (point-min) (point-max)
土屋さん>                             '(shift_jis euc-japan euc-korea)))

土屋さん> ということをすると、"Invalid or duplicated element in
土屋さん> argument" と怒られてしまいます。

こんな感じでしょうか。w3m-fsf.el 用です。

(defun w3m-detect-coding-region (start end &optional priority-list)
  "Detect coding system of the text in the region between START and END.
Return the first possible coding system.

PRIORITY-LIST is a list of coding systems ordered by priority."
  (let (category categories)
    (dolist (codesys priority-list)
      (setq category (coding-system-category codesys))
      (unless (assq category categories)
	(push (cons category codesys) categories)))
    (car (detect-coding-with-priority start end (nreverse categories)))))
-- 
Katsumi Yamaoka <yamaoka@namazu.org>