Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: chr@nybo.no (Christian Nybø)
Subject: Re: check for a particular header before calling a washing function?
Date: 09 Dec 2002 23:54:43 +0100	[thread overview]
Message-ID: <87znrevm4s.fsf@nybo.no> (raw)
In-Reply-To: <84r8cs8p9e.fsf@lucy.cs.uni-dortmund.de>

kai.grossjohann@uni-duisburg.de (Kai Großjohann) writes:

> chr@nybo.no (Christian Nybø) writes:
> 
> > Correct.  My Emacs is an XEmacs, btw.  I see two-character
> > combinations.
> 
> Aha.  Okay, you have a non-mule XEmacs.  The first step to fix this
> is to install a Mule XEmacs.
> 
> Then, get the Mule-UCS package and the Latin-Unity package and enable
> both.
> 
> I think that should solve your problems.

I think that it's overkill for my needs.  I added this to my .gnus:


(defun utf-8-decode-region (start end)
  (interactive "r")
  (let 	((work-buffer (generate-new-buffer " *utf-8-work*")))
    (unwind-protect
	(save-excursion
	  (buffer-disable-undo work-buffer)
	  (progn 
	    (goto-char start)
	    (while (not (eobp))
	      (cond 
	       ((zerop (logand (following-char) #x80)) ; high bit is not set
		(insert-char (following-char) 1 t work-buffer))
	       ((= (logand #xE0 (following-char)) #xC0)
		(insert-char (logior (lsh (logand (following-char) #b00011111) 6) 
				     (progn (forward-char) (logand (following-char) #b00111111)))
			     1 t work-buffer)))
	      (forward-char))
	    (or (markerp end) (setq end (set-marker (make-marker) end)))
	    (goto-char start)
	    (insert-buffer-substring work-buffer)
	    (delete-region (point) end)))
      (and work-buffer (kill-buffer work-buffer)))))

(defun gnus-article-de-utf-8 ()
  "Convert utf-8 to latin-1"
  (interactive)
  (save-excursion
    (set-buffer gnus-article-buffer)
    (let ((buffer-read-only nil))
      (widen)
      (goto-char (point-min))
      (search-forward "\n\n" nil t)
      (utf-8-decode-region (point) (point-max)))))

(define-key gnus-summary-mode-map "Wu" 'gnus-article-de-utf-8)

(defun gnus-article-maybe-de-utf-8 ()
  (let* ((ct (message-fetch-field "Content-Type" t))
	 (ctlist (and ct (mail-header-parse-content-type ct))))
    (when (string=
	   (cdr (assoc 'charset
		       (cdr ctlist)))
	   "utf-8")
      (gnus-article-de-utf-8))))

thus articles encoded in utf-8 consisting of characters in the range
from 0 to 255 are displayed nicely.

Thanks for your time.
-- 
chr


      parent reply	other threads:[~2002-12-09 22:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <877kemocp2.fsf@nybo.no>
2002-12-07  8:01 ` Bijan Soleymani
     [not found] ` <84n0nirlfi.fsf@lucy.cs.uni-dortmund.de>
     [not found]   ` <87vg25mz2u.fsf@nybo.no>
     [not found]     ` <847kelpkhj.fsf@lucy.cs.uni-dortmund.de>
2002-12-07 22:59       ` Christian Nybø
     [not found]         ` <84r8cs8p9e.fsf@lucy.cs.uni-dortmund.de>
2002-12-09 22:54           ` Christian Nybø [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87znrevm4s.fsf@nybo.no \
    --to=chr@nybo.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).