From: Robert Pluim <rpluim@gmail.com>
To: 60750@debbugs.gnu.org
Subject: bug#60750: 29.0.60; encode-coding-char fails for utf-8-auto coding system
Date: Thu, 12 Jan 2023 10:08:31 +0100 [thread overview]
Message-ID: <87zgaof7cg.fsf@gmail.com> (raw)
src/emacs -Q
M-x toggle-debug-on-error
M-: (setq buffer-file-coding-system 'utf-8-auto)
C-b
C-u C-x =
=>
Debugger entered--Lisp error: (args-out-of-range "))" 3 1)
encode-coding-char(41 utf-8-auto ascii)
describe-char(189)
what-cursor-position((4))
This is because utf-8-auto has a non-nil :bom property:
(define-coding-system 'utf-8-auto
"UTF-8 (auto-detect signature (BOM))"
:coding-type 'utf-8
:mnemonic ?U
:charset-list '(unicode)
:bom '(utf-8-with-signature . utf-8))
and `encode-coding-char' does this:
;; We also need to exclude the leading 2 or 3 bytes if they
;; come from a BOM.
(setq i0
(if bom-p
(cond
((eq (coding-system-type coding-system) 'utf-8)
3)
((eq (coding-system-type coding-system) 'utf-16)
2)
(t 0))
0))
(substring enc2 i0 i2)))))
Iʼm not sure if this needs fixing, but it was surprising, and the
docstring of `define-coding-system' didnʼt make it clear to me whether
a BOM should have been produced here or not. (Iʼm willing to be told
that buffer-file-coding-system shouldnʼt be 'utf-8-auto, but I never
set that explicitly as far as I know 😀)
Thanks
Robert
In GNU Emacs 29.0.60 (build 14, x86_64-pc-linux-gnu, GTK+ Version
3.24.24, cairo version 1.16.0) of 2023-01-12 built on rltb
Repository revision: f4f30ff4c44dcfdf780f1981aa541af713f2805f
Repository branch: emacs-29
System Description: Debian GNU/Linux 11 (bullseye)
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB
next reply other threads:[~2023-01-12 9:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 9:08 Robert Pluim [this message]
2023-01-12 12:32 ` bug#60750: 29.0.60; encode-coding-char fails for utf-8-auto coding system Eli Zaretskii
2023-01-12 13:44 ` Robert Pluim
2023-01-12 14:04 ` Eli Zaretskii
2023-01-12 14:28 ` Robert Pluim
2023-01-12 14:39 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zgaof7cg.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=60750@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).