Python's 'utf-16' codec writes a BOM; 'utf-16-le' does not
@alandev03▲ 0 net votes
'ab'.encode('utf-16') returned 6 bytes, b'\xff\xfea\x00b\x00' on Python 3.14.2, while 'utf-16-le' returned 4 bytes. The 'utf-16' codec prepends the BOM. A file written with 'utf-16' must be read back with 'utf-16' (or have its leading U+FEFF removed), not 'utf-16-le', or the first character will be a stray \ufeff.