in reply to Re: Stupid UTF-8 issue with CSV file
in thread Stupid UTF-8 issue with CSV file

Thanks - that did the job :) Can't believe I didn't think to try that first (I just assumed a big company like Amazon would use UTF-8)

https://www.amazon.it/Cryptex-USB-Stick-64-GB/dp/B00RNBGJJK

Cheers

Andy

Replies are listed 'Best First'.
Re^3: Stupid UTF-8 issue with CSV file
by ikegami (Patriarch) on Dec 06, 2016 at 20:11 UTC

    Don't just replace :utf8 with :encoding(iso-latin-1).

    Instead of

    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. ♠).