From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Encoding/decoding problems
Date: Thu, 28 Jul 2011 08:18:16 -0400 [thread overview]
Message-ID: <E1QmPXc-0007lS-U8@fencepost.gnu.org> (raw)
In-Reply-To: <4E312B5D.6090600@dogan.se> (message from Deniz Dogan on Thu, 28 Jul 2011 11:26:53 +0200)
> Date: Thu, 28 Jul 2011 11:26:53 +0200
> From: Deniz Dogan <deniz@dogan.se>
>
> (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.
"Encoding" means converting Emacs's internal representation into an
external representation you want to send to a disk file or another
program. "Decoding" is the opposite conversion: from an external
representation that you found in a disk file or received from a
network socket to the internal representation Emacs uses in its buffer
and string objects.
So you want "decode-" functions, in this case decode-coding-string,
since you've got the external representation in a string.
next prev parent reply other threads:[~2011-07-28 12:18 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
2011-07-28 10:01 ` Jambunathan K
2011-07-28 12:18 ` Eli Zaretskii [this message]
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=E1QmPXc-0007lS-U8@fencepost.gnu.org \
--to=eliz@gnu.org \
--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).