[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
UTF16 encoding adds BOM everywhere?
From: |
Jean Abou Samra |
Subject: |
UTF16 encoding adds BOM everywhere? |
Date: |
Thu, 14 Jul 2022 21:16:44 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 |
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
- UTF16 encoding adds BOM everywhere?,
Jean Abou Samra <=