in reply to Problems parsing UTF16 file
I don't know how to post the file and keep the encoding. So below is some of the file displayed using vi in the hex mode.
Like this
#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw' pp '; use Encode::Detective qw' detect '; my $file = shift or die "Usage: $0 filename > data.pl \n"; my $data = do { open my($fh), '<:raw' , $file or die $!; local $/; <$fh>; }; my $encoding = detect($data); print q{my $data = }, pp($data), "; open my(\$fh), '<:$encoding', \\\$data or die; ... "; __END__ my $data = "\xFE\xFF\0h\0i\0\r\0\n"; open my($fh), '<:UTF-16BE', \$data or die; ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problems parsing UTF16 file
by stu23 (Initiate) on Aug 10, 2012 at 17:52 UTC |