# New Ticket Created by Phill Wolf # Please include the string: [perl #24077] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=24077 > Writing a "Unicode" (little-endian) text file in Windows, Perl corrupts the byte stream by writing 1-byte carriage-returns rather than 2-byte. require v5.8.1; use charnames ('BYTE ORDER MARK'); open(FH, ">:encoding(UCS-2LE)", "malformed.txt"); print FH "\N{BYTE ORDER MARK}"; print FH "a\n"; print FH "b\n"; close(FH); Debug shows the following bytes in the file: FE FF 61 00 0D 0A 00 62-00 0D 0A 00 ..a....b.... Note how 0D isn't getting a trailing 00 byte.Thread Next