[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 cfd2b3504a: Fix encoding with 'utf-8-auto'
From: |
Eli Zaretskii |
Subject: |
emacs-29 cfd2b3504a: Fix encoding with 'utf-8-auto' |
Date: |
Thu, 12 Jan 2023 09:38:07 -0500 (EST) |
branch: emacs-29
commit cfd2b3504ab5de6eb5f3c7a0784cb447883e1326
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Fix encoding with 'utf-8-auto'
* src/coding.c (encode_coding_utf_8): Fix encoding with
'utf-8-auto': it should produce BOM, per the documentation of
the :bom attribute. (Bug#60750)
* lisp/international/mule.el (define-coding-system): Doc fix.
* test/src/coding-tests.el (coding-tests): Use
'with-coding-priority' instead of 'prefer-coding-system', as the
latter has global persistent effect and affects further tests.
---
lisp/international/mule.el | 3 ++-
src/coding.c | 2 +-
test/src/coding-tests.el | 30 +++++++++++++++---------------
3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 4f6addea38..eddd7b6407 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -863,7 +863,8 @@ This attribute is meaningful only when `:coding-type' is
`utf-16' or
VALUE must be `big' or `little' specifying big-endian and
little-endian respectively. The default value is `big'.
-This attribute is meaningful only when `:coding-type' is `utf-16'.
+Changing this attribute is only meaningful when `:coding-type'
+is `utf-16'.
`:ccl-decoder' (required if :coding-type is `ccl')
diff --git a/src/coding.c b/src/coding.c
index 4e59f2b6a1..49dcd8634f 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1431,7 +1431,7 @@ encode_coding_utf_8 (struct coding_system *coding)
ptrdiff_t produced_chars = 0;
int c;
- if (CODING_UTF_8_BOM (coding) == utf_with_bom)
+ if (CODING_UTF_8_BOM (coding) != utf_without_bom)
{
ASSURE_DESTINATION (3);
EMIT_THREE_BYTES (UTF_8_BOM_1, UTF_8_BOM_2, UTF_8_BOM_3);
diff --git a/test/src/coding-tests.el b/test/src/coding-tests.el
index 6bd8d1ae6c..b27907027b 100644
--- a/test/src/coding-tests.el
+++ b/test/src/coding-tests.el
@@ -148,21 +148,21 @@
(defun coding-tests (content-type write-coding read-coding detected-coding
&optional translator)
- (prefer-coding-system 'utf-8-auto)
- (let ((filename (coding-tests-filename content-type write-coding)))
- (with-temp-buffer
- (let ((coding-system-for-read read-coding)
- (contents (coding-tests-file-contents content-type))
- (disable-ascii-optimization nil))
- (if translator
- (setq contents (funcall translator contents)))
- (insert-file-contents filename)
- (if (and (coding-system-equal buffer-file-coding-system detected-coding)
- (string= (buffer-string) contents))
- nil
- (list buffer-file-coding-system
- (string-to-list (buffer-string))
- (string-to-list contents)))))))
+ (with-coding-priority '(utf-8-auto)
+ (let ((filename (coding-tests-filename content-type write-coding)))
+ (with-temp-buffer
+ (let ((coding-system-for-read read-coding)
+ (contents (coding-tests-file-contents content-type))
+ (disable-ascii-optimization nil))
+ (if translator
+ (setq contents (funcall translator contents)))
+ (insert-file-contents filename)
+ (if (and (coding-system-equal buffer-file-coding-system
detected-coding)
+ (string= (buffer-string) contents))
+ nil
+ (list buffer-file-coding-system
+ (string-to-list (buffer-string))
+ (string-to-list contents))))))))
(ert-deftest ert-test-coding-ascii ()
(unwind-protect
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 cfd2b3504a: Fix encoding with 'utf-8-auto',
Eli Zaretskii <=