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

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

Bug in mule.el/sgml-xml-auto-coding-function


From: Jirka Kosek
Subject: Bug in mule.el/sgml-xml-auto-coding-function
Date: Thu, 28 Apr 2005 13:48:15 +0200
User-agent: Mozilla Thunderbird 0.9 (Windows/20041103)

Hi,

function sgml-xml-auto-coding-function tries to detect encoding of XML file. XML specification allows encoding name to be surrounded by quotes or apostrophes. Current code expect only quotes so it won't detect encoding if specified as:

<?xml version="1.0" encoding='windows-1250'?>

The following function has corrected RE in order to deal with both delimiters.

(defun sgml-xml-auto-coding-function (size)
  "Determine whether the buffer is XML, and if so, its encoding.
This function is intended to be added to `auto-coding-functions'."
  (setq size (+ (point) size))
  (when (re-search-forward "\\`[[:space:]\n]*<\\?xml" size t)
    (let ((end (save-excursion
                 ;; This is a hack.
                 (re-search-forward "[\"']\\s-*\\?>" size t))))
      (when end
        (if (re-search-forward "encoding=[\"']\\(.+?\\)[\"']" end t)
            (let* ((match (match-string 1))
                   (sym (intern (downcase match))))
              (if (coding-system-p sym)
                  sym
                (message "Warning: unknown coding system \"%s\"" match)
                nil))
          'utf-8)))))


TIA,

                                Jirka

--
------------------------------------------------------------------
  Jirka Kosek     e-mail: jirka@kosek.cz     http://www.kosek.cz
------------------------------------------------------------------
  Profesionální školení a poradenství v oblasti technologií XML.
     Podívejte se na náš nově spuštěný web http://DocBook.cz
       Podrobný přehled školení http://xmlguru.cz/skoleni/
------------------------------------------------------------------

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


reply via email to

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