unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* UTF16 encoding adds BOM everywhere?
@ 2022-07-14 19:16 Jean Abou Samra
  2022-07-20 20:42 ` Mark H Weaver
  0 siblings, 1 reply; 3+ messages in thread
From: Jean Abou Samra @ 2022-07-14 19:16 UTC (permalink / raw)
  To: Guile User

Hi,

With this code:

(let ((p (open-output-file "x.txt")))
   (set-port-encoding! p "UTF16")
   (display "ABC" p)
   (close-port p))

the sequence of bytes in the output file x.txt is

['FF', 'FE', '41', '0', 'FF', 'FE', '42', '0', 'FF', 'FE', '43', '0']

FFE is a little-endian Byte Order Mark (BOM), fine.
But why is Guile adding it before every character
instead of just at the beginning of the string?
Is that expected?

This is a curiosity question; since what I want is
big endian, I just used "UTF16BE", which outputs
big endian, and doesn't add the BOM -- I can then just
add a BOM manually. Still, I'm puzzled by this
behavior.

Thanks,
Jean




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-20 21:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14 19:16 UTF16 encoding adds BOM everywhere? Jean Abou Samra
2022-07-20 20:42 ` Mark H Weaver
2022-07-20 21:45   ` Jean Abou Samra

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).