#======================================================== # UTF8Code #======================================================== package UTF8Code; use strict; use utf8; use Encode; use JFile; #============================================================ # コンストラクタ、デストラクタ #============================================================ sub new { my ($module) = @_; my $this = {}; bless $this; return $this; } #============================================================ # 一般関数 #============================================================ sub MakeHankakuFile { my ($App, $outfile, $Content) = @_; #return $Content; use utf8; use Encode; my $utf8 = find_encoding('utf8'); my $eucjp = find_encoding('eucjp'); my $sjis = find_encoding('sjis'); $App->print("Write to [$outfile]\n"); my $out = new JFile($outfile, "w"); if(!$out) { $App->print(" Error: Can not write to [$outfile].\n"); return 0; } $Content = decode("sjis", $Content); $Content =~ tr/[!-~ ]/[!-~ ]/; $Content =~ s/([!-~]) ([!-~])/$1 $2/g; # my $reg = "A-Za-z0-9 -‐,、。."; # $Content =~ tr/[$reg]/[A-Za-z0-9 --,,..]/; $out->print($sjis->encode($Content)); $out->Close(); no utf8; no Encode; return $Content; } 1;