�����ܤμ��ؤκ�ȯ�����狼��ʤ����ɡ����Ĥ���ʤ��ä���Τϸ��Ĥ���ʤ��ä��Τǡ�

ezip.pl

�����˺���������ϡ������顣

#!/usr/bin/env perl
#
# $Id: ezip.pl,v 0.1 2010/09/06 13:52:00 dankogai Exp dankogai $
#
use strict;
use warnings;
use Archive::Zip qw/:ERROR_CODES/;
use Getopt::Std;
use Encode;
use Unicode::Normalize;    # to handle UTF-8-MAC

my %opt = ( e => 'UTF-8' );
getopts( "e:" => \%opt );
my $encode = do {
    my $enc = find_encoding( $opt{e} ) or die "unknown encoding: $opt{e}";
    sub { $enc->encode( Unicode::Normalize::NFC( decode_utf8(shift) ) ) };
};

my $zipfile = shift; 
die "$0 -e encoding archive.zip path ..." unless @ARGV;
my $zip = Archive::Zip->new;
$zip->addTree($_, $_) for @ARGV;
my $error;
for my $m ( $zip->members() ) {
    $m->fileName( $encode->( $m->fileName ) );
}
$error = $zip->writeToFileNamed($zipfile) and die "$zipfile : error $error";

SYNOPSIS

% ezip.pl -e cp932 4win.zip ���ܸ�����ä�path ��

convzip.pl

��¸��zip������������windows�Ѥ˻�Ω��ľ���Ȥ��ˤϡ������顣

#!/usr/bin/env perl
#
# $Id: convzip.pl,v 0.1 2010/09/06 13:52:00 dankogai Exp dankogai $
#
use strict;
use warnings;
use Archive::Zip qw/:ERROR_CODES/;
use Getopt::Std;
use Encode;
use Unicode::Normalize;    # to handle UTF-8-MAC

my %opt = ( e => 'UTF-8' );
getopts( "e:" => \%opt );
my $encode = do {
    my $enc = find_encoding( $opt{e} ) or die "unknown encoding: $opt{e}";
    sub { $enc->encode( Unicode::Normalize::NFC( decode_utf8(shift) ) ) };
};

my ( $srcfile, $dstfile ) = @ARGV;
die "$0 -e encoding from.zip to.zip" unless $dstfile;
my $zip = Archive::Zip->new;
my $error;
$error = $zip->read($srcfile) and die "$srcfile : error $error";
for my $m ( $zip->members() ) {
    $m->fileName( $encode->( $m->fileName ) );
}
$error = $zip->writeToFileNamed($dstfile) and die "$dstfile : error $error";

SYNOPSIS

% convzip.pl -e cp932 ���ܸ�����ä�.zip 4win.zip

��Ĺ����¾

  • Win¦�ǥե�����̾��ľ��������ץȤϸ����Ǹ��Ĥ���ޤ�����convmv��¸�ߤ��ΤäƤ����ΤǤ��������̤���¦���н褹�륹����ץȤ���������ʤ��ä��ΤǤ������ޤ�����
  • Mac�ʳ��Ǥ⤿���Ƥ���Unix�Ķ��ʤ�ư���ޤ����Ȥꤢ����FreeBSD��Ubuntu�Ǥϳ�ǧ�Ѥ�
  • Archive::Zip::Member�Υɥ�����Ȥ��ʤ��Ƥ���äȶ�ϫ���ޤ�������$m->fileName()�˰����������Ȥ����rename�Ǥ��뤳�Ȥò¥½¡ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½É¤ï¿½ï¿½ï¿½Î¤ï¿½Þ¤ï¿½ï¿½ï¿½ï¿½ï¿½

Enjoy!

Dan the Man with Too Many Encodings to Handle