我有一个编码为 PC UTF-8 的文件。我想将文件转换为 PC ANSI。
我已经尝试过以下方法,但我总是将输出文件设为 PC UTF-8。
use Encode;
$infile = $ARGV[0];
open(INFILE, $infile);
my $outfile = "temp.txt";
open(OUTFILE, ">$outfile");
while(<INFILE>) {
my $row = $_;
chomp $row;
$row = Encode::encode("Windows-1252", $row);
print OUTFILE $row."\n";
}
close INFILE;
close OUTFILE;