my $qfn = $CFG->{admin_root_path}."/amazon_template_tmp/it_other.csv";
open(my $fh, '>:encoding(iso-latin-1)', $qfn)
or die("Can't create \"$qfn\": $!\n");
print($fh $the_contents);
use
use Encode qw( encode );
my $qfn = $CFG->{admin_root_path}."/amazon_template_tmp/it_other.csv";
open(my $fh, '>:raw', $qfn)
or die("Can't create \"$qfn\": $!\n");
print($fh encode('iso-latin-1', $the_contents, Encode::FB_HTMLCREF));
That way, characters that can't be encoded using iso-latin-1 will be replaced with HTML escapes (e.g. ♠ ⇒ ♠).
|