Is the [0xff, 0xfe] prefix required on utf-16 encoded strings?
Rewritten question! I am working with a vendor's device that requires "unicode encoding" of strings, where each character is represented in two bytes. My strings will always be ASCII based, so I thought this would be the way to translate my string into the vendor's string: >>> b1 = 'abc'.encode('utf-16') But examining the result, I see that there's a leading [0xff, 0xfe] on the bytearray: >>> [hex(b) for b in b1] ['0xff', '0xfe', '0x61', '0x0', '0x62', '0x0', '0x63', '0x0'] Since the vendor's device is not expecting the [0xff, 0xfe], I can strip it off... >>> b2 = 'abc'.encode('utf-16')[2:] >>