From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Julien Danjou Newsgroups: gmane.emacs.devel Subject: Re: url-retrieve-synchronously and coding Date: Mon, 24 Jan 2011 16:11:29 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: dough.gmane.org 1295881908 28711 80.91.229.12 (24 Jan 2011 15:11:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 24 Jan 2011 15:11:48 +0000 (UTC) Cc: Stefan Monnier , Emacs-Devel devel To: Lennart Borgman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 24 16:11:44 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PhO51-0008Jd-Gb for ged-emacs-devel@m.gmane.org; Mon, 24 Jan 2011 16:11:43 +0100 Original-Received: from localhost ([127.0.0.1]:37730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhO50-0007Ri-OY for ged-emacs-devel@m.gmane.org; Mon, 24 Jan 2011 10:11:42 -0500 Original-Received: from [140.186.70.92] (port=35990 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhO4s-0007Qm-Ta for emacs-devel@gnu.org; Mon, 24 Jan 2011 10:11:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PhO4r-0003SU-Kn for emacs-devel@gnu.org; Mon, 24 Jan 2011 10:11:34 -0500 Original-Received: from coquelicot-s.easter-eggs.com ([213.215.37.94]:49261) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PhO4r-0003S3-EG for emacs-devel@gnu.org; Mon, 24 Jan 2011 10:11:33 -0500 Original-Received: from cigue.easter-eggs.fr (cigue.easter-eggs.fr [10.0.0.33]) by rose.easter-eggs.fr (Postfix) with ESMTPS id AB771141AC; Mon, 24 Jan 2011 16:11:26 +0100 (CET) Original-Received: from jdanjou by cigue.easter-eggs.fr with local (Exim 4.72) (envelope-from ) id 1PhO4o-0005zF-0d; Mon, 24 Jan 2011 16:11:30 +0100 Mail-Followup-To: Lennart Borgman , Stefan Monnier , Emacs-Devel devel In-Reply-To: (Lennart Borgman's message of "Mon, 24 Jan 2011 13:21:16 +0100") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:134892 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Jan 24 2011, Lennart Borgman wrote: > Ok, thanks. It is not easy to navigate among those functions. But I > guess we have said before that better documentation is needed. > > Unfortunately url-insert-file-contents does not decode the file as > utf-8. mm-disect-buffer looks for the charset, but only in the mime > headers. In this case the charset is specified instead in the xml > content. > > I do not know how the retrieved content above should be handled. It > looks however like the web browsers handles this case and shows the > xml content correctly. Probably because your browser understand XML. Firefox seems to. > It seems natural in a case like this where Content-Type is text/xml to > look for the specified charset in the xml content. I think > `url-insert' should do this. Here is a suggestion for how to do it > where I just have added a search for : Damn no, I don't think *url*-insert should parse XML, or you'll end up parsing a lot of file type. This is not what url is about. What you need is another layer on top of mm (or enhance mm) with something like this: #+begin_src emacs-lisp (defvar mm-decoder-helper-functions '(("text/xml" . 'mm-decoder-xml-helper))) (defun mm-decoder-xml-helper (string-or-buffer) "Return the encoding type of a XML." This function read a XML string or a buffer containing XML (this depends on the API type you chose to implement) and return it's encoding. ...) (defun mm-decoder-please-decode-this (content content-type &optional conten= t-encoding) "Decode CONTENT based on CONTENT-TYPE and possibly CONTENT-ENCODING." Here you use content-encoding if provided, or a helper from=20 `mm-decoder-helper-functions' to find the good content based on `content-type'. ...) #+end_src That is just a raw idea. Feel free to enhance. :) =2D-=20 Julien Danjou =E2=9D=B1 http://julien.danjou.info --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAk09lqEACgkQpGK1HsL+5c26CACg1/cv69QU3KE9IxoQpIdv6X/D bNsAoJ8rQG1kftDkkODuakbMxWZs3K+j =LqjK -----END PGP SIGNATURE----- --=-=-=--