From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jambunathan K Newsgroups: gmane.emacs.help Subject: Re: Encoding/decoding problems Date: Thu, 28 Jul 2011 15:31:39 +0530 Message-ID: <81tya6hgfw.fsf@gmail.com> References: <4E311B3C.7040301@dogan.se> <4E312B5D.6090600@dogan.se> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1311847335 6864 80.91.229.12 (28 Jul 2011 10:02:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 28 Jul 2011 10:02:15 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Deniz Dogan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 28 12:02:08 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QmNPr-0001gD-4z for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Jul 2011 12:02:07 +0200 Original-Received: from localhost ([::1]:51444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmNPq-000841-Dp for geh-help-gnu-emacs@m.gmane.org; Thu, 28 Jul 2011 06:02:06 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:40175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmNPl-00083T-4C for help-gnu-emacs@gnu.org; Thu, 28 Jul 2011 06:02:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QmNPj-0008QF-Rk for help-gnu-emacs@gnu.org; Thu, 28 Jul 2011 06:02:01 -0400 Original-Received: from mail-gw0-f49.google.com ([74.125.83.49]:45626) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmNPj-0008Q5-Jw for help-gnu-emacs@gnu.org; Thu, 28 Jul 2011 06:01:59 -0400 Original-Received: by gwb1 with SMTP id 1so1971941gwb.36 for ; Thu, 28 Jul 2011 03:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=iZscc1cfijkKgUkFeull4sfeK5d7fd9z4mFUmZhEqd0=; b=fWfQ417+fYO/60ufxBVgWa+RFhwCuwyV5K+gmptqSM/D5h+VeKl9INRgiyrHT+2XuB mBDnOMViVsOKDCRHL2leb0bJ5cnU2KzhjJBpgKTWFhbY9K+iQThfyLviDOvrAZEJ3Jmb tPGxT+20vx1jgN5irK65iqp38zAi6zb5C0NNA= Original-Received: by 10.68.23.166 with SMTP id n6mr1461812pbf.469.1311847317760; Thu, 28 Jul 2011 03:01:57 -0700 (PDT) Original-Received: from JAMBU-NETBOOK ([115.184.68.72]) by mx.google.com with ESMTPS id v2sm624267pbi.19.2011.07.28.03.01.53 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jul 2011 03:01:57 -0700 (PDT) In-Reply-To: <4E312B5D.6090600@dogan.se> (Deniz Dogan's message of "Thu, 28 Jul 2011 11:26:53 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (windows-nt) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.83.49 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81837 Archived-At: Deniz Dogan writes: > On 2011-07-28 11:01, Eli Zaretskii wrote: >>> Date: Thu, 28 Jul 2011 10:18:04 +0200 >>> From: Deniz Dogan >>> >>> I'm fetching an XML document that's uses iso-8859-1 coding with >>> `url-retrieve' and then I parse it using `xml-parse-region'. >>> >>> After that, I get the parts of the document that I want and insert them >>> into a buffer. However, the Swedish characters =E5, =E4 and =F6 are di= splayed >>> as \345, \344 and \326 respectively. >>> >>> I've tried messing around with `encode-coding-region' and >>> `decode-coding-region' but I'm really not sure what to do here. >> >> I suggest to start with describing a reproducible recipe for this >> problem. Not sure if this forum is appropriate, perhaps emacs-devel >> is a better place (as it sounds like you are describing a bug). >> > > Here is the code to reproduce it: > > (defun fetch-and-show () > (interactive) > (let* ((old-buffer (current-buffer)) > (url "http://dogan.se/sites/default/files/example.xml") > (buffer (url-retrieve-synchronously url))) > (with-current-buffer buffer > (let ((doc (car (xml-parse-region (point-min) (point-max))))) > (with-current-buffer old-buffer > (insert > (nth 2 (nth 2 (nth 3 doc))))))))) > > The XML file is encoded in iso-8859-1 with a bunch of Swedish > characters here and there. The buffer I'm testing this with is > *scratch* with utf-8-unix. It should insert "hall=E5" but inserts > "hall\345". FWIW, this works as expected. Note the use of decode coding string. (defun fetch-and-show () (interactive) (let* ((old-buffer (current-buffer)) (url "http://dogan.se/sites/default/files/example.xml") (buffer (url-retrieve-synchronously url))) (with-current-buffer buffer (let ((doc (car (xml-parse-region (point-min) (point-max))))) (with-current-buffer old-buffer (insert (decode-coding-string (nth 2 (nth 2 (nth 3 doc))) 'iso-8859-1))))))) > > I have no idea whether I should use `encode-region-string' or > decode-region-string' or what. I'd doubt it's a bug to be honest, > it's probably my lack of understanding that's causing this. > > Deniz > > --=20