annotate lisp/nxml/nxml-enc.el @ 97404:4b2fa911beae

*** empty log message ***
author Glenn Morris <rgm@gnu.org>
date Sun, 10 Aug 2008 20:18:12 +0000
parents c3512b2085a0
children b8e68a14e5c2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1 ;;; nxml-enc.el --- XML encoding auto-detection
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2
87665
b9e8ab94c460 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86535
diff changeset
3 ;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
4
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
5 ;; Author: James Clark
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
6 ;; Keywords: XML
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
7
86535
5b3df8d4a15b Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
8 ;; This file is part of GNU Emacs.
5b3df8d4a15b Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
9
94666
d495d4d5452f Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87665
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
86535
5b3df8d4a15b Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94666
d495d4d5452f Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87665
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
d495d4d5452f Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87665
diff changeset
13 ;; (at your option) any later version.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
14
86535
5b3df8d4a15b Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
5b3df8d4a15b Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
5b3df8d4a15b Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5b3df8d4a15b Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
18 ;; GNU General Public License for more details.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
19
86535
5b3df8d4a15b Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94666
d495d4d5452f Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87665
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
22
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
23 ;;; Commentary:
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
24
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
25 ;; User entry points are nxml-start-auto-coding and
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
26 ;; nxml-stop-auto-coding. This is separate from nxml-mode, because
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
27 ;; this cannot be autoloaded. It may use
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
28 ;; `xmltok-get-declared-encoding-position' which can be autoloaded.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
29 ;; It's separate from rng-auto.el so it can be byte-compiled, and
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
30 ;; because it provides independent, useful functionality.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
31
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
32 ;;; Code:
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
33
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
34 (defvar nxml-file-name-ignore-case
97142
c3512b2085a0 * bitmaps/README:
Dan Nicolaescu <dann@ics.uci.edu>
parents: 94666
diff changeset
35 (memq system-type '(windows-nt)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
36
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
37 (defvar nxml-cached-file-name-auto-coding-regexp nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
38 (defvar nxml-cached-auto-mode-alist nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
39
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
40 (defun nxml-file-name-auto-coding-regexp ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
41 "Return regexp for filenames for which XML auto-coding should be done."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
42 (if (eq auto-mode-alist nxml-cached-auto-mode-alist)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
43 nxml-cached-file-name-auto-coding-regexp
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
44 (let ((alist auto-mode-alist)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
45 (case-fold-search nxml-file-name-ignore-case)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
46 regexps)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
47 (setq nxml-cached-auto-mode-alist alist)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
48 (while alist
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
49 (when (eq (cdar alist) 'nxml-mode)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
50 (setq regexps (cons (caar alist) regexps)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
51 (setq alist (cdr alist)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
52 (setq nxml-cached-file-name-auto-coding-regexp
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
53 (if (null (cdr regexps))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
54 (car regexps)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
55 (mapconcat (lambda (r)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
56 (concat "\\(?:" r "\\)"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
57 regexps
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
58 "\\|"))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
59
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
60 (defvar nxml-non-xml-set-auto-coding-function nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
61 "The function that `set-auto-coding-function' should call for non-XML files.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
62 (defun nxml-set-auto-coding (file-name size)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
63 (if (let ((case-fold-search nxml-file-name-ignore-case)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
64 (regexp (nxml-file-name-auto-coding-regexp)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
65 (and regexp
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
66 (string-match regexp file-name)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
67 (nxml-set-xml-coding file-name size)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
68 (and nxml-non-xml-set-auto-coding-function
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
69 (funcall nxml-non-xml-set-auto-coding-function file-name size))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
70
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
71 (defun nxml-set-xml-coding (file-name size)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
72 "Function to use as `set-auto-coding-function' when file is known to be XML."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
73 (nxml-detect-coding-system (+ (point) (min size 1024))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
74
86535
5b3df8d4a15b Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
75 (declare-function xmltok-get-declared-encoding-position "xmltok"
5b3df8d4a15b Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
76 (&optional limit)) ; autoloaded
5b3df8d4a15b Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
77
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
78 (defun nxml-detect-coding-system (limit)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
79 (if (< limit (+ (point) 2))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
80 (if (eq (char-after) 0) 'no-conversion 'utf-8)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
81 (let ((first-two-chars (list (char-after)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
82 (char-after (1+ (point))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
83 (cond ((equal first-two-chars '(#xFE #xFF))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
84 (and (coding-system-p 'utf-16-be) 'utf-16-be))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
85 ((equal first-two-chars '(#xFF #xFE))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
86 (and (coding-system-p 'utf-16-le) 'utf-16-le))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
87 ((memq 0 first-two-chars)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
88 ;; Certainly not well-formed XML;
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
89 ;; perhaps UTF-16 without BOM.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
90 ;; In any case, we can't handle it.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
91 ;; no-conversion gives the user a chance to fix it.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
92 'no-conversion)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
93 ;; There are other things we might try here in the future
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
94 ;; eg UTF-8 BOM, UTF-16 with no BOM
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
95 ;; translate to EBCDIC
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
96 (t
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
97 (let ((enc-pos (xmltok-get-declared-encoding-position limit)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
98 (cond ((consp enc-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
99 (or (nxml-mime-charset-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
100 (buffer-substring-no-properties (car enc-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
101 (cdr enc-pos)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
102 ;; We have an encoding whose name we don't recognize.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
103 ;; What to do?
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
104 ;; raw-text seems the best bet: since we got
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
105 ;; the XML decl it must be a superset of ASCII,
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
106 ;; so we don't need to go to no-conversion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
107 'raw-text))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
108 (enc-pos 'utf-8)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
109 ;; invalid XML declaration
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
110 (t nil))))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
111
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
112 (defun nxml-mime-charset-coding-system (charset)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
113 (let ((charset-sym (intern (downcase charset)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
114 (coding-systems (coding-system-list t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
115 coding-system ret)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
116 (while (and coding-systems (not ret))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
117 (setq coding-system (car coding-systems))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
118 (if (eq (coding-system-get coding-system 'mime-charset)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
119 charset-sym)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
120 (setq ret coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
121 (setq coding-systems (cdr coding-systems))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
122 ret))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
123
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
124 (defun nxml-start-auto-coding ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
125 "Do encoding auto-detection as specified in the XML standard.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
126 Applied to any files that `auto-mode-alist' says should be handled by
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
127 `nxml-mode'."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
128 (interactive)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
129 (unless (eq set-auto-coding-function 'nxml-set-auto-coding)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
130 (let ((inhibit-quit t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
131 (setq nxml-non-xml-set-auto-coding-function set-auto-coding-function)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
132 (setq set-auto-coding-function 'nxml-set-auto-coding))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
133
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
134 (defun nxml-stop-auto-coding ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
135 "Stop doing encoding auto-detection as specified in the XML standard."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
136 (interactive)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
137 (when (eq set-auto-coding-function 'nxml-set-auto-coding)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
138 (let ((inhibit-quit t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
139 (setq set-auto-coding-function nxml-non-xml-set-auto-coding-function)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
140 (setq nxml-non-xml-set-auto-coding-function nil))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
141
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
142 (unless (coding-system-p 'us-ascii)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
143 (make-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
144 ;; Unicode Emacs uses ?- last time I looked
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
145 'us-ascii 2 ?-
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
146 "ISO 2022 based 7-bit encoding for ASCII (MIME:US-ASCII)"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
147 '(ascii)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
148 '((safe-charsets ascii)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
149 (mime-charset . us-ascii))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
150
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
151 ;; Emacs 21.3.50 makes us-ascii an alias for iso-safe without
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
152 ;; giving it a mime-charset property.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
153 (unless (coding-system-get 'us-ascii 'mime-charset)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
154 (coding-system-put 'us-ascii 'mime-charset 'us-ascii))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
155
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
156 ;; Work around bug in Emacs 21.3
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
157
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
158 (when (and (coding-system-p 'utf-16-le)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
159 (eq (coding-system-get 'utf-16-le 'pre-write-conversion)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
160 'utf-16-le-pre-write-conversion))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
161 (coding-system-put 'utf-16-le 'pre-write-conversion nil))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
162
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
163 (when (and (coding-system-p 'utf-16-le)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
164 (eq (coding-system-get 'utf-16-be 'pre-write-conversion)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
165 'utf-16-be-pre-write-conversion))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
166 (coding-system-put 'utf-16-be 'pre-write-conversion nil))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
167
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
168 (provide 'nxml-enc)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
169
86379
2ac1a9b70580 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 86361
diff changeset
170 ;; arch-tag: c2436247-78f3-418c-8069-85dc5335d083
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
171 ;;; nxml-enc.el ends here