From unknown Sat Aug 16 22:00:30 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#8283 <8283@debbugs.gnu.org> To: bug#8283 <8283@debbugs.gnu.org> Subject: Status: sgml-xml-auto-coding-function() should respect the *-with-signature-* coding Reply-To: bug#8283 <8283@debbugs.gnu.org> Date: Sun, 17 Aug 2025 05:00:30 +0000 retitle 8283 sgml-xml-auto-coding-function() should respect the *-with-sign= ature-* coding reassign 8283 emacs submitter 8283 LIN Sumang severity 8283 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 18 09:33:31 2011 Received: (at submit) by debbugs.gnu.org; 18 Mar 2011 13:33:31 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q0Zo2-0007pl-D0 for submit@debbugs.gnu.org; Fri, 18 Mar 2011 09:33:31 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q0TpT-00075w-VB for submit@debbugs.gnu.org; Fri, 18 Mar 2011 03:10:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q0TpN-0002DR-O0 for submit@debbugs.gnu.org; Fri, 18 Mar 2011 03:10:30 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_LOW,T_DKIM_INVALID,T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:34686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q0TpM-0002D9-He for submit@debbugs.gnu.org; Fri, 18 Mar 2011 03:10:29 -0400 Received: from [140.186.70.92] (port=55343 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q0TpF-00088C-PC for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2011 03:10:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q0TpD-0002Ak-Mg for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2011 03:10:20 -0400 Received: from mail-iy0-f169.google.com ([209.85.210.169]:60851) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q0TpD-0002Af-Ge for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2011 03:10:19 -0400 Received: by iyf13 with SMTP id 13so4566630iyf.0 for ; Fri, 18 Mar 2011 00:10:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=SNd9OQ3VhZOI4rmkdeHGxPJ97SOGnVHdxZ7sQlNQ0eE=; b=IUzbBILnQ1+uNaQ7DhaaBJGLUAyU3XXfTL7YQKlxMmNZwcKQI94JuKvupje56IEvU5 LLIR+FNUFEEHWg6h0cZsLp9bgQtALjjPLOnCB4PvuWURXntsoEQPlZA3WC7GIVdBWc+H 7R72R54vj85U5TMeGTaLX3eDhKTy6vjJNgve0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=R+NwDlpmPC/s/aQY1I3sGt7MxK7LS9kqxbAqRvT6f/+dZBOwMoz6/tV7gti8o8RYC6 eCsqzXgcUS5YUfeqkCYNPdBuaqep9DKUmNwiA8LmykCJ/6fr/N4J6An0e5hyV9eMBxKS Jn2ccomOuo7s1qgws4bv5+zTFvKu4qp6WPR84= MIME-Version: 1.0 Received: by 10.43.65.72 with SMTP id xl8mr1048195icb.211.1300432218641; Fri, 18 Mar 2011 00:10:18 -0700 (PDT) Received: by 10.42.195.77 with HTTP; Fri, 18 Mar 2011 00:10:18 -0700 (PDT) In-Reply-To: References: Date: Fri, 18 Mar 2011 15:10:18 +0800 Message-ID: Subject: Re: sgml-xml-auto-coding-function() should respect the *-with-signature-* coding From: LIN Sumang To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary=bcaec51ddcb77254f9049ebc7886 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 18 Mar 2011 09:33:28 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) --bcaec51ddcb77254f9049ebc7886 Content-Type: text/plain; charset=ISO-8859-1 I wrote a simple function for *workaround*. Hope it helps. (defun sgml-xml-auto-coding-function-utf (size) (let* ((selected-coding (sgml-xml-auto-coding-function size)) (selected (symbol-name selected-coding)) (current-coding buffer-file-coding-system) (current (symbol-name current-coding)) ) (if (and (string-match "^utf-" selected) (string-match "^utf-.+\\(-with-signature.*\\)" current)) (if (string= selected (substring current 0 (length selected))) current-coding ;; current=utf-cc-xxxx; selected=utf-ss; new -> utf-ss-xxxx (let ((sig (match-string 1 current)) new) (string-match "^utf-\\(.+\\)" selected) (setq new (match-string 1 selected)) (setq new (intern (concat "utf-" new sig))) (if (coding-system-p new) new selected-coding ))) selected-coding)) ) On Fri, Mar 18, 2011 at 1:56 PM, LIN Sumang wrote: > Hi, > > I am using Emacs 23.2.1. I think sgml-xml-auto-coding-function() should > respect the *-with-signature-* coding. > > Consider the scenario below: > 1. xml file with the signature \376\377 at beginning of the file and the > first line is > > 2. edit this file and save it. sgml-xml-auto-coding-function will use the > utf-16be to save the file. > 3. open the file again, get messed. > > In this case sgml-xml-auto-coding-function() shouldn't change the coding > and if it really need to change the coding, it should append the > *-with-signature-* to the selected coding. > > sgml-html-meta-auto-coding-function() should have same problem. > > > --bcaec51ddcb77254f9049ebc7886 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I wrote a simple function for workaround. Hope it helps.

(defun sgml-xml-auto-codi= ng-function-utf (size)
=A0 (let* ((selected-co= ding (sgml-xml-auto-coding-function size))
=A0=A0=A0=A0=A0=A0=A0=A0 (selected (symbol-name selected-coding)) =A0=A0=A0=A0=A0=A0=A0= =A0 (current-coding buffer-file-coding-system)
=A0=A0=A0=A0=A0=A0=A0=A0 (current (symbol-name current-coding))=
=A0=A0=A0=A0=A0=A0=A0= =A0 )
=A0=A0=A0 (if (and (string-match &= quot;^utf-" selected)
=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 (string-match "^utf-.+\\(-with-signature.*\\)" cu= rrent))
=A0=A0=A0=A0=A0=A0=A0 (if (string= =3D selected (substring current 0 (length selected)))
=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 current-coding
=A0=A0=A0=A0= =A0=A0=A0=A0=A0 ;; current=3Dutf-cc-xxxx; selected=3Dutf-ss; new -> utf-= ss-xxxx
=A0=A0=A0=A0=A0=A0=A0= =A0=A0 (let ((sig (match-string 1 current))
=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 (string-match "^utf-\\(.+\\)" selected)
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (setq new (match-str= ing 1 selected))
=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 (setq new (intern (concat "utf-" new sig)))=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (if (coding-syst= em-p new)
=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0 new
=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 selected-coding
=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 )))
=A0=A0=A0=A0=A0 sel= ected-coding))
=A0=A0=A0 )

On Fri, Mar 18, 2011 at 1:56 PM, LIN Sumang <linsumang@gmail.com> wrote:
Hi,

I am u= sing Emacs 23.2.1. I think sgml-xml-auto-coding-function() should respect t= he *-with-signature-* coding.

Consider the scenario below:
1. xml file with the signature \376\377= at beginning of the file and the first line is
<?xml version=3D"1.0" encoding=3D"utf-16be"?>
= 2. edit this file and save it. sgml-xml-auto-coding-function will use the u= tf-16be to save the file.
3. open the file again, get messed.

In = this case sgml-xml-auto-coding-function() shouldn't change the coding a= nd if it really need to change the coding, it should append the *-with-sign= ature-* to the selected coding.

sgml-html-meta-auto-coding-function() should have same problem.

=

--bcaec51ddcb77254f9049ebc7886-- From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 18 13:03:22 2011 Received: (at control) by debbugs.gnu.org; 18 Mar 2011 17:03:23 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q0d58-000428-Jt for submit@debbugs.gnu.org; Fri, 18 Mar 2011 13:03:22 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q0d57-00041g-0x for control@debbugs.gnu.org; Fri, 18 Mar 2011 13:03:21 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1Q0d52-00082N-2a for control@debbugs.gnu.org; Fri, 18 Mar 2011 13:03:16 -0400 Date: Fri, 18 Mar 2011 13:03:16 -0400 Message-Id: Subject: control message for bug 8283 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.3 (------) merge 8282 8283 From debbugs-submit-bounces@debbugs.gnu.org Sat May 18 03:26:24 2019 Received: (at control) by debbugs.gnu.org; 18 May 2019 07:26:25 +0000 Received: from localhost ([127.0.0.1]:59506 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hRtjc-0005Yr-Ji for submit@debbugs.gnu.org; Sat, 18 May 2019 03:26:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42231) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hRtjb-0005Yb-3C; Sat, 18 May 2019 03:26:23 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:42915) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRtjT-0001Vs-Qv; Sat, 18 May 2019 03:26:17 -0400 Received: from [176.228.60.248] (port=1700 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hRtjS-0007fS-R2; Sat, 18 May 2019 03:26:15 -0400 Date: Sat, 18 May 2019 10:26:09 +0300 Message-Id: <83ef4w9qb2.fsf@gnu.org> From: Eli Zaretskii To: npostavs@gmail.com In-reply-to: <85a7fldp15.fsf@gmail.com> (npostavs@gmail.com) Subject: Re: bug#35766: emacs saves utf-16 le xml files as utf-16 be References: <837eaqcl9g.fsf@gnu.org> <83lfz5bfed.fsf@gnu.org> <87a7fle1yp.fsf@gmail.com> <83tvdt9js7.fsf@gnu.org> <85a7fldp15.fsf@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control Cc: jszabo_98@hotmail.com, 35766@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) merge 8282 35766 close 36766 thanks > From: npostavs@gmail.com > Cc: Noam Postavsky , jszabo_98@hotmail.com, 35766@debbugs.gnu.org > Date: Fri, 17 May 2019 12:27:50 -0400 > > Eli Zaretskii writes: > > > Perhaps we should by default produce encoding with BOM when XML header > > specifies UTF-16? > > I think yes, https://www.w3.org/TR/xml/#charencoding says > > Entities encoded in UTF-16 MUST [...] begin with the Byte Order Mark OK, I did that as well, and pushed the changes to master. > By the way, is Bug#8282 the same as this one, or just closely related? It's the same problem; merged the bugs. > It's talking about sgml-html-meta-auto-coding-function (though maybe > sgml-xml-auto-coding-function is more relevant). I'm getting a little > confused between all the different *-find/auto-coding-* functions. The function relevant for the recipe in bug#8282 is sgml-xml-auto-coding-function, which is where I made the changes. If the HTML and/or SGML specs also mandate that we use BOM, then maybe we need the same changes in sgml-html-meta-auto-coding-function as well. Note that there's no equivalent for xml-find-file-coding-system for non-XML files, so recognition of visited UTF-16 HTML files will not work even if they do have a BOM. > There is also nxml-set-auto-coding which seems to be mostly unused. It is supposed to be used by packages that build on top of nXml, AFAIU. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat May 18 03:44:25 2019 Received: (at control) by debbugs.gnu.org; 18 May 2019 07:44:25 +0000 Received: from localhost ([127.0.0.1]:59517 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hRu13-00085c-IX for submit@debbugs.gnu.org; Sat, 18 May 2019 03:44:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44432) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hRu10-00085O-K7 for control@debbugs.gnu.org; Sat, 18 May 2019 03:44:22 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:43049) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRu0v-00077e-FD for control@debbugs.gnu.org; Sat, 18 May 2019 03:44:17 -0400 Received: from [176.228.60.248] (port=2805 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hRu0u-00084m-3Q for control@debbugs.gnu.org; Sat, 18 May 2019 03:44:16 -0400 Date: Sat, 18 May 2019 10:44:10 +0300 Message-Id: <83d0kg9ph1.fsf@gnu.org> From: Eli Zaretskii To: control@debbugs.gnu.org Subject: Close 35766 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 35766 thanks From debbugs-submit-bounces@debbugs.gnu.org Sat May 18 07:29:41 2019 Received: (at control) by debbugs.gnu.org; 18 May 2019 11:29:42 +0000 Received: from localhost ([127.0.0.1]:60028 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hRxX3-0007bX-N2 for submit@debbugs.gnu.org; Sat, 18 May 2019 07:29:41 -0400 Received: from mail-io1-f50.google.com ([209.85.166.50]:44917) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hRxX1-0007bK-FN for control@debbugs.gnu.org; Sat, 18 May 2019 07:29:39 -0400 Received: by mail-io1-f50.google.com with SMTP id f22so7483743iol.11 for ; Sat, 18 May 2019 04:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=kuE16Gblw+x5ogjh+rDlj3sS44QwGRcJC498d0FMm4Y=; b=e9/H1mgTBkb4NbK1fm2aydFImAzZS1rtlS9TvnnV1kQYaVCUMgPFWKWi0ut0U67ipK ag2Nc0+YyqA1aB0LUNk1iBvmHdyQ76CT8zsj1h27hKw6Ax55Dn9573s7oYzhsoPMNFKD HMNKwiVTfzpfKPF3SK0L//ioXw6UAcZDH2TMOIom+IVfqrn/cHqPddfcpNpazXpjvpuj vrh+NV0neRwcaC5O7qhcWvs8RU0Zk0+HD4kByq+Tb/CLC93zF48r2VECiAk1Hi/bIhun qcsKK1zvGzM0RBR9kwBjWHncOSBRSLYNSkhWCegBRClLBItclvQNFk+N96HlDQ/xJaoQ uWKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=kuE16Gblw+x5ogjh+rDlj3sS44QwGRcJC498d0FMm4Y=; b=dVSIDk3/RfTI+pAqVytuIq+Ztf65ofLkaMU00b/J3bSXQPsc//u7I/lGOkNUlbxXoe a4XVvL8jq+YDhj88TFzpECnLtfIxG5HMe9fQhAXH1Zon/RUxfw1AFmdlNMf40PSZc4nP FRs5IlSK6qR7xhjemqBdpaNq1OaDZVeTPl+neVB7GKWvvLxjo6673/tsA5IK9xTY7A68 y4nPgatNG/nk/cdbYBFn8ryZ/j2utpl4T733QAg4tevpGsZIZlXyOeoUorNWjxNpc/ZT I6I11xh0NMYUe1NYfPA3L7a6DwM29l+njhtPeprMtn0wCV5nidA8IYM2sdp9HdDxyMGV SCdA== X-Gm-Message-State: APjAAAXtqz4yxByt6st8h5hW+ZhxuDVUc3GBTjXIS2lr0VrD9o7BoXDe VKOGwAeDNA3l/ksEgZpMLG8/HGl7 X-Google-Smtp-Source: APXvYqxhdhSjQVf+H+s8rMiJmPNBCVyNAOrZ5gyeeNpMhyDaBDie9cJj+UbkoV1ymH9q6fViKeftQQ== X-Received: by 2002:a6b:dd07:: with SMTP id f7mr35463201ioc.244.1558178973745; Sat, 18 May 2019 04:29:33 -0700 (PDT) Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id x11sm3712463ion.10.2019.05.18.04.29.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 May 2019 04:29:32 -0700 (PDT) From: Noam Postavsky To: control@debbugs.gnu.org Subject: control message for bug #35766 Date: Sat, 18 May 2019 07:29:31 -0400 Message-ID: <874l5sdmqs.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) fixed 35766 27.1 quit From unknown Sat Aug 16 22:00:30 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 17 Jun 2019 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator