其实我必须解析一些可以以任何形式的endian(Big或Little)的文件。如果我使用一种编码和解析其他Perl解释器死亡。如何在perl中检查一个文件是写成little endian还是big endian?
open (my $fh, "<:raw:encoding(UTF-16LE):crlf", $ARGV[0]) or die cannot open file for reading : $! \n";
或
open (my $fh, "<:raw:encoding(UTF-16BE):crlf", $ARGV[0]) or die cannot open file for reading : $! \n";
输出(用于在LE文件和Perl的编码存在BE)
UTF-16BE:Malformed HI surrogate dc00 at toASCII.pl line 123.
[查找系统是perl或little endian或big endian](http://stackoverflow.com/questions/2610849/finding-if-the-system-is-little-endian-or-big -endian-with-perl) –
@EliSadoff这个问题询问如何查找特定的*文件*是大还是小的,而不是系统是否是。 – ThisSuitIsBlackNot
为什么“my $ fh”在引号中? :-O – choroba