亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 5168 | 回復(fù): 4
打印 上一主題 下一主題

perl Win32::GUI 中文顯示為亂碼,求助 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2014-06-14 01:44 |只看該作者 |倒序?yàn)g覽
[ 本帖最后由 hmlijg 于 2014-06-14 02:00 編輯 ]

從一個網(wǎng)友的帖子里復(fù)制的perl代碼,他提供的exe文件中文顯示正常,我用他的代碼重新生成exe文件后中文顯示為亂碼(圖片在帖子末尾),請問各位高手,這是什么原因?



源代碼:

#!/usr/bin/perl

# Written by Limeng
# April 1, 2012 Changsha
# 僅掃描大小相同的文件,大量節(jié)省掃描時間
# 改進(jìn)耗時顯示格式
# 改寫GUI

use strict;
#use warnings;
use Win32::GUI qw( MB_ICONINFORMATION MB_OK );
use Win32::GUI::DropFiles();
use Encode qw/ encode /;
use Win32::OLE qw(in);
use Digest::MD5;
use Benchmark;

my $about= <<EOF;
/`\\ /`\\
(/\\ V /\\)        Limeng's Clone Files Finder V3.0
  /6 6\\          -- Written by Limeng o_*, April, 2012
>{= Y =}<
/'-^-'\\         All Rights Reserved 2010-3000 ChangSha
(_)""-(_)        Homepage: [url=http://limeng.class22.net]http://limeng.class22.net[/url]
                 E-mail: iamlimeng\@163.com
BlueIdea!
EOF

my $clone_report_file;
my %paths;
my @file_list;

my $w_m = 700;
my $h_m = 400;
my $icon = new Win32::GUI::Icon("icon.ico");
my $wm_class = new Win32::GUI::Class(
         -name => 'Limeng',
         -icon => $icon,
);

my $main = Win32::GUI::Window->new(
        -title => " Limeng's Clone Files Finder V3.0",
        -class => $wm_class,
        -size  => [$w_m,$h_m],
        -maximizebox        => 0,
        -dialogui        => 1,
        -noflicker        => 1,
        -onResize => \&mwResize,
);

$main->AddLabel(
        -name => 'L1',
        -pos  => [($w_m-190)/2,15],
        -size  => [$w_m,20],
        -text => "請將要查找的目錄拖拽進(jìn)下面的框!",
);

$main->AddButton(
        -name => 'B1',
        -pos  => [150,$h_m-70],
        -text => " 開 始 分 析 ",
        -default => 1,
        -ok      => 1,
        -visible => 1,
        -onClick => \&FindClone,
);

$main->AddButton(
        -name => 'B2',
        -pos  => [300,$h_m-70],
        -text => " 分 析 報 告 ",
        -default => 1,
        -ok      => 1,
        -visible => 1,
        -onClick => \&OpenReport,
);

$main->AddButton(
        -name => 'B3',
        -pos  => [450,$h_m-70],
        -text => " 關(guān) 于 程 序 ",
        -default => 1,
        -ok      => 1,
        -visible => 1,
        -onClick => \&About,
);

$main->AddListbox(
        -name => 'LB',
        -pos => [10,40],
        -vscroll => 1,
        -acceptfiles => 1,
        -onClick => \&changeTitle,
        -onDblClick => \&deleteSelect,
        -onDropFiles => \&gotDrop,
);

my ($DOS) = Win32::GUI::GetPerlWindow();
Win32::GUI::Hide($DOS);
$main->B2->Disable();
$main->Center();
#$main->Maximize();
$main->Show();
Win32::GUI::Dialog();
$main->Hide();
undef $main;
exit(0);

sub gotDrop {
        my ($self, $dropObj) = @_;
        my @files = $dropObj->GetDroppedFiles();
        foreach (sort @files) {
                 my $full_name = encode('gbk',$_);
                 if (-d $full_name) {
                          $self->Add($full_name) if (!$paths{$full_name});
                          $paths{$full_name} = 1;
                 }
        }
        return 0;
}

sub deleteSelect {
         my $self = shift;
         my $item = $self->GetText($self->GetCaretIndex());
         delete($paths{$item});
        $self->RemoveItem($self->GetCaretIndex());
        return 0;
}
sub changeTitle {
         my $self = shift;
         $main->L1->Change(-text => '雙擊選中的項(xiàng),可將其從列表中刪除!');
        return 0;
}

sub mwResize {
        my $self = shift;
        $self->LB->Resize($self->ScaleWidth()-20,280);
        return 1;
}

sub About {
        my $self = shift;
        $self->MessageBox("$about","關(guān)于本程序...",MB_ICONINFORMATION | MB_OK,);
        return 0;
}

sub OpenReport {
        my $self = shift;
        $main->B1->Change(-text => " 開 始 分 析 ");
        $main->B1->Enable();
        if (-e $clone_report_file) { system("$clone_report_file"); }
         else {
                 $self->MessageBox("指定的目錄未發(fā)現(xiàn)重復(fù)文件!","分析報告...",MB_ICONINFORMATION | MB_OK,);
         }
        return 0;
}

sub FindClone {
        my $self = shift;
         my $time = &get_time;
        my $error_file = "錯誤信息報告_$time.txt";
        $clone_report_file = "重復(fù)文件報告_$time.txt";
        my $TT0 = new Benchmark;
        $main->B1->Disable();
        $main->B2->Disable();
        my @error;

         #獲得目錄清單
        my @path_list;
         my $list = $main->LB->GetCount();
         foreach (0 .. $list-1) {
                 push(@path_list,$main->LB->GetText($_));
         }

        # scan files from the given directories
         $main->B1->Change(-text => '掃描目錄...');
        @file_list = ();
        foreach (@path_list) { readsub($_); }

        # search files with the same size
        my $n = 1;
        my %same_size;
        foreach my $file(@file_list) {
                 my $percent = int($n/($#file_list+1)*100);
                 $main->B1->Change(-text => "分析中...$percent %");
                 my @stat = stat($file);
                 push(@{$same_size{$stat[7]}},$file);
                 $n++;
        }
        my @files_with_same_size;
        foreach (keys %same_size) {
                 if (@{$same_size{$_}} > 1) {
                         push(@files_with_same_size,@{$same_size{$_}});
                 }
        }

        my $clone;
        if (@files_with_same_size) {
                 my $same_size_total = $#files_with_same_size+1;

                 # Compare files with the same size
                 my $n = 1;
                 my %clone;
                 foreach my $file(@files_with_same_size) {
                          my $percent = int($n/($same_size_total+1)*100);
                           $main->B1->Change(-text => "比較中...$percent %");
                          open(FILE, $file) or push(@error,"$file\t$!");
                          binmode(FILE);
                          my $md5 = Digest::MD5->new->addfile(*FILE)->hexdigest();
                          close FILE;
                          push(@{$clone{$md5}},$file);
                          $n++;
                 }

                 # generate clone report
                  my $check = 0;
                  foreach (keys %clone) {
                          if (@{$clone{$_}} > 1) {
                                 $check++;
                                 last;
                         }
                  }

                  if ($check) {
                          open FH, ">$clone_report_file";
                          print FH "已分析目錄:\n";
                          foreach (@path_list) { print FH "$_\n"; }
                           print FH "\n";
                          print FH "創(chuàng)建時間        \t大小\t文件名\n";
                          print FH "="x100,"\n";
                          foreach (keys %clone) {
                                   if (@{$clone{$_}} > 1) {
                                           foreach(@{$clone{$_}}) {
                                                    my @stat = stat($_);
                                                    print FH time_transfer($stat[9]),"\t",int($stat[7]/1024+0.5)," KB\t$_\n";
                                           }
                                           print FH "\n";
                                           $clone++;
                                   }
                          }
                  }
        }
        $main->B1->Change(-text => " 分 析 結(jié) 束 ");

         # return analyze message
         my $message;
        if ($clone) {
                 $message = "共發(fā)現(xiàn) $clone 組重復(fù)文件,詳情請點(diǎn)擊\"分析報告\"!";
                 print FH "共發(fā)現(xiàn) $clone 組重復(fù)文件!";
                 close FH;
                 $main->B2->Enable();
        }
        else {
                $message = "指定的目錄未發(fā)現(xiàn)重復(fù)文件!";
                 $main->B1->Enable();
                 $main->B2->Disable();
        }

        if (@error) {
                 open FH,">$error_file";
                 foreach (@error) { print FH "$_\n"; }
                 close FH;
                  my $errors = $#error+1;
                 $message .= "\n\n發(fā)生了 $errors 個錯誤,詳見 \"$error_file\"!";
        }

        # display the time spent
        my $TT1 = new Benchmark;
        my $td = Benchmark::timediff($TT1, $TT0);
        $td = Benchmark::timestr($td);
        my ($sec) = ($td =~ /(\d+).*/);
        my $time_display;
        if ($sec >= 60) {
                 my $hour;
                 my $minute = int($sec/60);
                 if ($minute >= 60) {
                         $hour = int($minute/60);
                         $minute = $minute % 60;
                 }
                 my $second = $sec % 60;
                 $time_display .= " $hour 小時" if ($hour);
                 $time_display .= " $minute 分鐘" if ($minute);
                 $time_display .= " $second 秒" if ($second);
        }
        else { $time_display = " $sec 秒"; }
        $message .= "\n\n分析耗時:$time_display";
        $self->MessageBox("$message","分析報告...",MB_ICONINFORMATION | MB_OK,);
        return 0;
}

sub readsub
{
        my $file_t = shift;
        if (-f $file_t) {
                push(@file_list,$file_t);
        }
        if (-d $file_t) {
                opendir(AA,$file_t);
                my @list = readdir(AA);
                close (AA);
                my $file_to_act;
                foreach $file_to_act (sort @list)
                {
                        if ($file_to_act =~ /^\.|\.$/) { next; }
                        else
                        {
                                readsub("$file_t/$file_to_act");
                        }
                }
        }
}

sub get_time {
        my ($sec,$min,$hour,$day,$mon,$year,$weekday,$yeardate,$savinglightday) = (localtime(time()));
        #$sec = ($sec < 10)? "0$sec":$sec;
        $min = ($min < 10)? "0$min":$min;
        $hour = ($hour < 10)? "0$hour":$hour;
        $day = ($day < 10)? "0$day":$day;
        $mon = ($mon < 9)? "0".($mon+1):($mon+1);
        $year += 1900;
        return("$year-$mon-$day $hour.$min");
}

sub time_transfer {
        my $time_str = shift;
        my ($sec,$min,$hour,$day,$mon,$year,$weekday,$yeardate,$savinglightday) = (localtime($time_str));
        #$sec = ($sec < 10)? "0$sec":$sec;
        $min = ($min < 10)? "0$min":$min;
        $hour = ($hour < 10)? "0$hour":$hour;
        $day = ($day < 10)? "0$day":$day;
        $mon = ($mon < 9)? "0".($mon+1):($mon+1);
        $year += 1900;
        return("$year-$mon-$day $hour:$min");
}

捕獲.JPG (50.71 KB, 下載次數(shù): 37)

捕獲.JPG

論壇徽章:
0
2 [報告]
發(fā)表于 2014-06-18 15:28 |只看該作者
換換你源碼的文件編碼試試

論壇徽章:
0
3 [報告]
發(fā)表于 2014-07-07 09:14 |只看該作者
換為ANSI一切正常,謝謝回復(fù) 2# tmp


   

論壇徽章:
0
4 [報告]
發(fā)表于 2014-07-10 10:15 |只看該作者
這是我的代碼啊

論壇徽章:
0
5 [報告]
發(fā)表于 2014-07-10 10:17 |只看該作者
是的,謝謝你
回復(fù) 4# iamlimeng


   
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP