[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 ec6f588: Better support utf-8-with-signature and
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] emacs-26 ec6f588: Better support utf-8-with-signature and utf-8-hfs in HTML |
Date: |
Sat, 11 Aug 2018 05:02:07 -0400 (EDT) |
branch: emacs-26
commit ec6f588940e51013435408a456c10d33ddf98fb2
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Better support utf-8-with-signature and utf-8-hfs in HTML
* lisp/international/mule.el (sgml-html-meta-auto-coding-function):
Support UTF-8 with BOM and utf-8-hfs as variants of UTF-8, and
obey the buffer's encoding if it is one of these variants, instead
of re-encoding in UTF-8 proper. (Bug#20623)
---
lisp/international/mule.el | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 4d0081f..1488810 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -2544,7 +2544,17 @@ This function is intended to be added to
`auto-coding-functions'."
(let* ((match (match-string 2))
(sym (intern (downcase match))))
(if (coding-system-p sym)
- sym
+ ;; If the encoding tag is UTF-8 and the buffer's
+ ;; encoding is one of the variants of UTF-8, use the
+ ;; buffer's encoding. This allows, e.g., saving an
+ ;; HTML file as UTF-8 with BOM when the tag says UTF-8.
+ (let ((sym-type (coding-system-type sym))
+ (bfcs-type
+ (coding-system-type buffer-file-coding-system)))
+ (if (and (coding-system-equal 'utf-8 sym-type)
+ (coding-system-equal 'utf-8 bfcs-type))
+ buffer-file-coding-system
+ sym))
(message "Warning: unknown coding system \"%s\"" match)
nil)))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-26 ec6f588: Better support utf-8-with-signature and utf-8-hfs in HTML,
Eli Zaretskii <=