in reply to UTF-16 on WinXP written by Perl shows whitespaces.
To expand on anonymonks terseness, you need to make sure that the file is read and written as binary to avoid newline translations. "pushing raw" translates to prefixing the encoding with ':raw'. The following works (copies a utf16le file with futzing with it) for me, but without the ':raw's, I see the same symptoms you describe.
#! perl -slw use strict; use PerlIO::encoding; open IN, '<:raw:encoding(UTF-16LE)', $ARGV[ 0 ]; open OUT, '>:raw:encoding(UTF-16LE)', $ARGV[ 0 ] . '.modified'; print OUT <IN>; close $_ for *IN, *OUT;
You can pass the same argument string to binmode
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: UTF-16 on WinXP written by Perl shows whitespaces.
by almut (Canon) on Nov 07, 2007 at 13:40 UTC | |
|
Re^2: UTF-16 on WinXP written by Perl shows whitespaces.
by aplonis (Pilgrim) on Nov 07, 2007 at 13:26 UTC | |
by moritz (Cardinal) on Nov 07, 2007 at 13:36 UTC |