vitoco has asked for the wisdom of the Perl Monks concerning the following question:
Hi! I need to update data in some files that are UTF-16LE BOM files, but I've found that the output files are being corrupted with an extra 0x0D char on every line. How could I avoid this? What am I missing?
#!perl use strict; use warnings; open IN, "<:encoding(UTF-16LE)", "in.xml"; open OUT, ">:encoding(UTF-16LE)", "out.xml"; while (<IN>) { print OUT $_; } close OUT; close IN;
As it could be seen, there are no chomp, explicit decode, or whatever in the loop, it is just printing what it was read. In the input file, each line ends with the hex sequence 0D-00-0A-00, but in the output the sequence is 0D-00-0D-0A-00, adding one byte.
BTW, I don't want to parse the XML files as such, I'll just map some values based on an external dictionary (using a pre-loaded hash)...
EDIT: typo... Thanks!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CR-LF on UTF-16LE files on Windows
by ikegami (Patriarch) on Nov 07, 2018 at 17:31 UTC | |
by vitoco (Hermit) on Nov 07, 2018 at 18:43 UTC | |
by ikegami (Patriarch) on Nov 07, 2018 at 19:18 UTC | |
by james28909 (Deacon) on Nov 08, 2018 at 00:04 UTC | |
by ikegami (Patriarch) on Nov 08, 2018 at 08:00 UTC | |
|