help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Encoding/decoding problems


From: Eli Zaretskii
Subject: Re: Encoding/decoding problems
Date: Thu, 28 Jul 2011 08:18:16 -0400

> Date: Thu, 28 Jul 2011 11:26:53 +0200
> From: Deniz Dogan <address@hidden>
> 
> (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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]