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

From: Eli Zaretskii <[email-masked]>
Date: Fri, 17 May 2019 12:26:34 +0300

> From: J S <[email-masked]>
> CC: "[email-masked]" <[email-masked]>
> Date: Thu, 16 May 2019 20:57:34 +0000
> 
> I should say that I'm using emacs for windows.  And it's preferring saving in big endian to little endian when
> this is the tag:
> 
> <?xml version="1.0" encoding="UTF-16"?>

This is the default, yes.  "C-h C utf-16 RET" says:

  UTF-16 (detect endian on decoding, use big endian on encoding with BOM).
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If you want to encode in UTF-16LE, you need to tell Emacs to do this
explicitly:

  C-x RET c utf-16le-with-signature RET C-x C-s

> Try saving this xml file and opening it again:
> 
> <?xml version="1.0" encoding="UTF-16LE"?>

AFAIU, encoding="UTF-16LE" is invalid in XML.  If you see this
documented somewhere in XML docs, please tell me where it is
described.