Gnus development mailing list
 help / color / mirror / Atom feed
From: Katsumi Yamaoka <yamaoka@jpl.org>
To: Christoph Conrad <christoph.conrad@gmx.de>
Cc: ding@gnus.org, bugs@gnus.org
Subject: Re: gnus-article-browse-html-article' and character encoding
Date: Wed, 05 Dec 2007 11:57:31 +0900	[thread overview]
Message-ID: <b4mlk89g86c.fsf@jpl.org> (raw)
In-Reply-To: <873auj0xo8.fsf@ID-24456.user.uni-berlin.de>

[-- Attachment #1: Type: text/plain, Size: 627 bytes --]

>>>>> Christoph Conrad wrote:
> No Gnus v0.7
> GNU Emacs 23.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.12.1)
>  of 2007-11-30 on brabbelbox
> 200 news.online.de InterNetNews NNRP server INN 2.3.5 ready (posting ok).

> `gnus-article-browse-html-article' should write also the character
> encoding of the html part to the file, e.g. with

> Content-Type: text/html;
> 	charset="UTF-8"

> german umlauts are not displayed correctly if the default character
> encoding is iso-8859-1.

> Best regards,
> Christoph

Is the attached patch what you need?  This will add the meta html
tag that specifies the charset to an html source.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1428 bytes --]

--- gnus-art.el~	2007-12-05 01:51:07 +0000
+++ gnus-art.el	2007-12-05 02:55:23 +0000
@@ -2803,7 +2803,34 @@
 		    (string-match "text/html" (car (mm-handle-type handle))))
 	       (let ((tmp-file (mm-make-temp-file
 				;; Do we need to care for 8.3 filenames?
-				"mm-" nil ".html")))
+				"mm-" nil ".html"))
+		     (charset (mail-content-type-get (mm-handle-type handle)
+						     'charset)))
+		 (when charset
+		   (with-current-buffer (mm-handle-buffer handle)
+		     (when (eq charset 'gnus-decoded)
+		       (insert (prog2
+				   (setq charset 'utf-8)
+				   (encode-coding-string (buffer-string)
+							 charset)
+				 (erase-buffer)
+				 (mm-disable-multibyte))))
+		     (setq charset (format "\
+<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\">"
+					   charset))
+		     (goto-char (point-min))
+		     (let ((case-fold-search t))
+		       (cond ((re-search-forward "\
+<meta[\t\n\r ]+http-equiv=\"content-type\"[^>]+>"
+						 nil t)
+			      (replace-match charset))
+			     ((re-search-forward "<head>[\t\n\r ]*" nil t)
+			      (insert charset "\n"))
+			     (t
+			      (re-search-forward "\
+<html\\(?:[\t\n\r ]+[^>]+\\|[\t\n\r ]*\\)>[\t\n\r ]*"
+						 nil t)
+			      (insert "<head>\n" charset "\n</head>\n"))))))
 		 (mm-save-part-to-file handle tmp-file)
 		 (add-to-list 'gnus-article-browse-html-temp-list tmp-file)
 		 (add-hook 'gnus-summary-prepare-exit-hook

       reply	other threads:[~2007-12-05  2:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <873auj0xo8.fsf@ID-24456.user.uni-berlin.de>
2007-12-05  2:57 ` Katsumi Yamaoka [this message]
2007-12-05  5:43   ` Christoph Conrad
2007-12-05  6:06   ` Christoph Conrad
2007-12-05  6:25     ` Katsumi Yamaoka
2007-12-05  6:39       ` Katsumi Yamaoka
2007-12-10  2:17         ` Katsumi Yamaoka
2007-12-10  6:26           ` Christoph Conrad
2007-12-10  6:27           ` Christoph Conrad

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=b4mlk89g86c.fsf@jpl.org \
    --to=yamaoka@jpl.org \
    --cc=bugs@gnus.org \
    --cc=christoph.conrad@gmx.de \
    --cc=ding@gnus.org \
    /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).