[Top][All Lists]

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

Re: Encoding/decoding problems

From: Deniz Dogan
Subject: Re: Encoding/decoding problems
Date: Thu, 28 Jul 2011 14:23:04 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0

On 2011-07-28 14:18, Eli Zaretskii wrote:
Date: Thu, 28 Jul 2011 11:26:53 +0200
From: Deniz Dogan<address@hidden>

(defun fetch-and-show ()
    (let* ((old-buffer (current-buffer))
           (url "";)
           (buffer (url-retrieve-synchronously url)))
      (with-current-buffer buffer
        (let ((doc (car (xml-parse-region (point-min) (point-max)))))
          (with-current-buffer old-buffer
             (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.

Thanks for the explanation and thank you to Jambunathan for the help.

It appeared that I had simply done the decoding at the wrong stage of the processing somehow (the real example is a lot larger).

Again, thanks


reply via email to

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