unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Deniz Dogan <deniz@dogan.se>
To: help-gnu-emacs@gnu.org
Subject: Re: Encoding/decoding problems
Date: Thu, 28 Jul 2011 11:26:53 +0200	[thread overview]
Message-ID: <4E312B5D.6090600@dogan.se> (raw)
In-Reply-To: <E1QmMTb-0000Dh-4N@fencepost.gnu.org>

On 2011-07-28 11:01, Eli Zaretskii wrote:
>> Date: Thu, 28 Jul 2011 10:18:04 +0200
>> From: Deniz Dogan<deniz@dogan.se>
>>
>> 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 å, ä and ö are displayed
>> 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å" but inserts "hall\345".

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



  reply	other threads:[~2011-07-28  9:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-28  8:18 Encoding/decoding problems Deniz Dogan
2011-07-28  9:01 ` Eli Zaretskii
2011-07-28  9:26   ` Deniz Dogan [this message]
2011-07-28 10:01     ` Jambunathan K
2011-07-28 12:18     ` Eli Zaretskii
2011-07-28 12:23       ` Deniz Dogan

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E312B5D.6090600@dogan.se \
    --to=deniz@dogan.se \
    --cc=help-gnu-emacs@gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).