我想从二进制(“.exe”)文件中获取 Unicode 字符串。
当我使用这样的代码时:
`unicode_str = re.compile( u'[\u0020-\u007e]{1,}',re.UNICODE )`
它有效,但它只返回分隔符号,所以当我尝试将量词更改为 3 时:
Python:
unicode_str = re.compile( u'[\u0020-\u007e]{3,}',re.UNICODE )
珀尔:
my @a = ( $file =~ /[\x{0020}-\x{007e}]{3,}/gs );
我只得到 ASCII 符号,所有 Unicode 符号都消失了。
我在哪里犯了错误,或者我可能对Unicode一无所知?
评论中的代码:
Python:
File = open( sys.argv[1], "rb" )
FileData = File.read()
File.close()
unicode_str = re.compile( u'[\u0020-\u007e]{3,}',re.UNICODE )
myList = unicode_str.findall(FileData)
for p in myList:
print p
珀尔:
$/ = "newline separator";
my $input = shift;
open( File, $input );
my $file = <File>;
close( File );
my @a = ( $file =~ /[\x{0020}-\x{007e}]{3,}/gs );
foreach ( @a ) { print "$_\n"; }