mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-26 07:33:47 +00:00
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.
This commit is contained in:
parent
53b47df822
commit
cfd2b3504a
@ -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')
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user