CC: | lackas [...] invicro.com |
Subject: | Using $Archive::Zip::UNICODE = 1 leads to warnings or errors when trying to extract data. |
Here is an example script running on a Linux system:
--------------------------------------------------
#!/bin/env perl
use strict;
use warnings;
use Archive::Zip;
use utf8;
my $zip = Archive::Zip->new;
local $Archive::Zip::UNICODE = 1;
my $member;
$member = $zip->addFile('/etc/passwd', 'pässwörd☃-1.txt');
# $member->{bitFlag} |= 0x0800;
$zip->writeToFileNamed("out.zip");
__END__
giving these warnings when run:
Wide character in print at /opt/invicro/lib/perl5/5.16.2/x86_64-linux/IO/Handle.pm line 417.
Wide character in print at /opt/invicro/lib/perl5/5.16.2/x86_64-linux/IO/Handle.pm line 417.
And (more importantly) resulting in this warning when trying to extract:
$ unzip -t out.zip
Archive: out.zip
file #1 (p?ssw?rd?-1.txt):
mismatch between local and central GPF bit 11 ("UTF-8"),
continuing with central flag (IsUTF8 = 1)
testing: p?ssw?rd?-1.txt OK
At least one warning-error was detected in out.zip.
Tools such as 7zip even completely refuse to extract such archives (see for instance http://sourceforge.net/p/sevenzip/discussion/45797/thread/75827792?page=3).
Enabling the
$member->{bitFlag} |= 0x0800;
line seem to avoid the issue.