in reply to Re: XLSX to CSV with high ASCII characters
in thread XLSX to CSV with high ASCII characters

That outputs
Nicolás,123
  • Comment on Re^2: XLSX to CSV with high ASCII characters

Replies are listed 'Best First'.
Re^3: XLSX to CSV with high ASCII characters
by poj (Abbot) on Aug 26, 2017 at 19:46 UTC

    It that what it shows in Excel ?

    poj

      Excel shows Nicholás properly, as does the CSV/text output of xls2csv. But my script, and your test script, both create output with á as á

      And, if I open bar.csv in Excel, I get Nicolás

      $ cat bar.pl #!/usr/bin/perl use strict; use Text::CSV; my $outputFile = 'bar.csv'; my $csv = Text::CSV->new ( { binary => 1, eol => "\n" } ) or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $fh, ">:encoding(utf8)", $outputFile or die "$outputFile: $!"; $csv->print ($fh, ['Nicolás',123]); close $fh or die "$outputFile: $!"; $ cat bar.csv Nicolás,123

        I cannot speak to your script as I don't know what's in the input file. But poj's script needs

        use utf8;

        at the top in order to tell Perl that the content of the source code is encoded as UTF-8. This causes the high character to be read correctly, and the remainder of the script to work as expected.

        Note that you will have to consider whether your terminal is set to display UTF-8 when viewing the contents of the output file.

        The way forward always starts with a minimal test.