Home: Perl Programming Help: Win32 Programming Help:
unicode utf-16le CR-LF problem

New User

Oct 9, 2006, 10:41 AM

Views: 6638
unicode utf-16le CR-LF problem

When you output utf-16, every char should be 2 (or perhaps 4 bytes long). But if any of the 16-bit chars contains a \x0a byte, that LF will be expanded to a CR-LF, destroying all unicodicity. Can't figure out how to do 'binary mode' output with unicode.


$_ = "\x{ff0a}\x{1234}"; 

open OUT, ">temp.txt";
binmode OUT, ":encoding(UTF-16le)";
print OUT;
close OUT;

# The output file contains five bytes: 0D 0A FF 34 12