Subject: bug#35766: emacs saves utf-16 le xml files as utf-16 be

From: Eli Zaretskii <[email-masked]>
Date: Sat, 18 May 2019 10:26:09 +0300

merge 8282 35766
close 36766
thanks

> From: [email-masked]
> Cc: Noam Postavsky <[email-masked]>,  [email-masked],  [email-masked]
> Date: Fri, 17 May 2019 12:27:50 -0400
> 
> Eli Zaretskii <[email-masked]> 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.