random access
random access

Reputation: 21

Change the character set of a file when extracting a zip

I have a zip file that I'm trying to decompress; there's a file inside it that has an encoded (I think UTF8?) filename and instead of "ímynd.dd" it's changing the name to "ímynd.dd"

this is my code:

use Archive::Zip qw( :ERROR_CODES );
my $testsArchive = "master.zip";
my $testsDirectory = "master/";
my $zip = Archive::Zip->new();
die 'read error' unless ( $zip->read( $testsArchive ) == AZ_OK );
$zip->extractTree( '', $testsDirectory );

You can download the zip file from here: https://github.com/log2timeline/dfvfs/archive/master.zip

I'm using version 1.57 of the library, on win7, perl 5.22.1. If I run the same code on OS X it works file, so it has something to do with the charset encoding on Windows, but I'm at a loss how to fix it.

Thanks!

Upvotes: 2

Views: 807

Answers (1)

Nagaraju
Nagaraju

Reputation: 1875

From cpan.org

$Archive::Zip::UNICODE

This variable governs how Unicode file and directory names are added to or extracted from an archive. If set, file and directory names are considered to be UTF-8 encoded. This is EXPERIMENTAL AND BUGGY (there are some edge cases on Win32). Please report problems.

    {
        local $Archive::Zip::UNICODE = 1;
        $zip->addFile('Déjà vu.txt');
    }

link:cpan

Upvotes: 4

Related Questions