unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* url-insert-file-contents does not use charset from a http-header
@ 2005-11-13 11:10 Juergen Hoetzel
  2005-11-16 19:06 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Juergen Hoetzel @ 2005-11-13 11:10 UTC (permalink / raw)


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

Hi,

I'm using emacs-cvs. Try to insert:

(url-insert-file-contents "http://www.hoetzel.info/test")

I changed url-insert-file-contents to use the charset supplied in a
response. Patch enclosed.

Jürgen

[-- Attachment #2: url-insert-file-contents-charset.patch --]
[-- Type: text/plain, Size: 1230 bytes --]

--- url-handlers.el.orig	2005-11-13 11:53:46.000000000 +0100
+++ url-handlers.el	2005-11-13 03:12:18.000000000 +0100
@@ -202,6 +202,7 @@
 (defun url-insert-file-contents (url &optional visit beg end replace)
   (let ((buffer (url-retrieve-synchronously url))
 	(handle nil)
+	(charset nil)
 	(data nil))
     (if (not buffer)
 	(error "Opening input file: No such file or directory, %s" url))
@@ -215,13 +216,14 @@
     (mm-destroy-parts handle)
     (if replace (delete-region (point-min) (point-max)))
     (save-excursion
+      (setq charset (mail-content-type-get (mm-handle-type handle)
+					     'charset))
       (let ((start (point)))
-	(insert data)
-	;; FIXME: for text/plain data, we sometimes receive a `charset'
-	;; annotation which we could use as a hint of the locale in use
-	;; at the remote site.  Not sure how/if that should be done.  --Stef
-	(decode-coding-inserted-region
-	 start (point) url visit beg end replace)))
+	(if charset
+	    (insert (mm-decode-string data (mm-charset-to-coding-system charset)))
+	  (progn
+	    (insert data)
+	    (decode-coding-inserted-region start (point) url visit beg end replace)))))
     (list url (length data))))
 
 (defun url-file-name-completion (url directory)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: url-insert-file-contents does not use charset from a http-header
  2005-11-13 11:10 url-insert-file-contents does not use charset from a http-header Juergen Hoetzel
@ 2005-11-16 19:06 ` Stefan Monnier
  2005-11-17 12:09   ` Klaus Straubinger
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2005-11-16 19:06 UTC (permalink / raw)
  Cc: emacs-devel

> I'm using emacs-cvs. Try to insert:

> (url-insert-file-contents "http://www.hoetzel.info/test")

> I changed url-insert-file-contents to use the charset supplied in a
> response. Patch enclosed.

Installed, thank you,


        Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: url-insert-file-contents does not use charset from a http-header
  2005-11-16 19:06 ` Stefan Monnier
@ 2005-11-17 12:09   ` Klaus Straubinger
  2005-11-18  3:53     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Klaus Straubinger @ 2005-11-17 12:09 UTC (permalink / raw)


>> I'm using emacs-cvs. Try to insert:
>
>> (url-insert-file-contents "http://www.hoetzel.info/test")
>
>> I changed url-insert-file-contents to use the charset supplied in a
>> response. Patch enclosed.
>
> Installed, thank you,
>
>
>         Stefan

For me, this leads to strange \201 characters in the buffer where the
insert takes place. I tested it with the URL "http://www.heise.de/"
which specifies the iso-8859-1 charset.

-- 
Klaus Straubinger

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: url-insert-file-contents does not use charset from a http-header
  2005-11-17 12:09   ` Klaus Straubinger
@ 2005-11-18  3:53     ` Stefan Monnier
  2005-11-18 16:13       ` Klaus Straubinger
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2005-11-18  3:53 UTC (permalink / raw)
  Cc: emacs-devel

> For me, this leads to strange \201 characters in the buffer where the
> insert takes place. I tested it with the URL "http://www.heise.de/"
> which specifies the iso-8859-1 charset.

It worked correctly for me.  Can you give a precise recipe?


        Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: url-insert-file-contents does not use charset from a http-header
  2005-11-18  3:53     ` Stefan Monnier
@ 2005-11-18 16:13       ` Klaus Straubinger
  2005-11-18 17:52         ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Klaus Straubinger @ 2005-11-18 16:13 UTC (permalink / raw)


Hallo Stefan,

>> For me, this leads to strange \201 characters in the buffer where the
>> insert takes place. I tested it with the URL "http://www.heise.de/"
>> which specifies the iso-8859-1 charset.
>
> It worked correctly for me.  Can you give a precise recipe?

Create a new buffer in the UTF-8 coding system and call the function with
the URL given above.

I should mention that I used Emacs 21.4. Maybe the mm-... functions
that are called inside make the difference.

-- 
Klaus Straubinger

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: url-insert-file-contents does not use charset from a http-header
  2005-11-18 16:13       ` Klaus Straubinger
@ 2005-11-18 17:52         ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2005-11-18 17:52 UTC (permalink / raw)
  Cc: emacs-devel

> Create a new buffer in the UTF-8 coding system and call the function with
> the URL given above.

> I should mention that I used Emacs 21.4. Maybe the mm-... functions
> that are called inside make the difference.

Yes, please try to reproduce it with Emacs-CVS.


        Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-11-18 17:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-13 11:10 url-insert-file-contents does not use charset from a http-header Juergen Hoetzel
2005-11-16 19:06 ` Stefan Monnier
2005-11-17 12:09   ` Klaus Straubinger
2005-11-18  3:53     ` Stefan Monnier
2005-11-18 16:13       ` Klaus Straubinger
2005-11-18 17:52         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).