all messages for Emacs-related lists mirrored at yhetil.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

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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.