[Top][All Lists]

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

auto-detecting encoding for XML

From: Colin Walters
Subject: auto-detecting encoding for XML
Date: 18 May 2002 22:27:51 -0400


Someone asked on the xml-resume-devel list about the problems they'd had
because Emacs decided that their XML file (encoded in utf-8) should be
encoded using `raw-text'.  

XML has an optional encoding="foo" parameter, used like:

<?xml version="1.0" encoding="UTF-8"?>

Wouldn't it be nice if Emacs could see that and automatically Do The
Right Thing?

The attached patch is an implementation.  The reason why I had to put
`sgml-xml-auto-coding-function' inside mule.el is because 1) we can't
autoload it from sgml-mode.el, since that would be more or less
equivalent to always loading sgml-mode.el, and 2) If we added it to
`auto-coding-functions' when sgml-mode.el was loaded, then it wouldn't
work the first time a user visited an XML file, since the encoding has
already been determined.  (Subsequently it would work, though).

2002-05-18  Colin Walters  <address@hidden>

        * international/mule.el (make-coding-system): Doc fixes.

        * international/mule.el (auto-coding-functions): New variable.
        (auto-coding-from-file-contents): Use it.
        (set-auto-coding): Update docs.
        (sgml-xml-auto-coding-function): New function.

Attachment: mule.patch
Description: Text document

reply via email to

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