newperlbie has asked for the wisdom of the Perl Monks concerning the following question:

Hi again. I am reading and parsing a CSV file,and I get this error: UTF-8 "\xA0" does not map to Unicode at test.pl line 103, <File> line 98. utf8 "\xB0" does not map to Unicode utf8 "\xE4" does not map to Unicode utf8 "\xB0" does not map to Unicode there are quite a lot of codes. I tried couple of encodings,got rid of few errors,but not all. Please suggest what encoding I need to use while opening the file Thanks

Replies are listed 'Best First'.
Re: UTF-8 mapping CSV file
by Corion (Patriarch) on Aug 08, 2018 at 09:07 UTC

    You use the correct encoding. Only the original producer of the file can tell you what the correct encoding is, but you can make some educated guesses:

    open my $fh, '<:encoding(Latin-1)', $filename or die "$filename: $!";
Re: UTF-8 mapping CSV file
by Tux (Canon) on Aug 08, 2018 at 11:49 UTC

    Why did you not post any example code of how you "parse" this CSV file? Does the CSV file contain a Byte-Order-Mark? Do you use a parsing module?

    CSV files do not have any means of "storing" the encoding other than having a BOM, which does not support all known encodings. The sender should tell you what the encoding is. Guessing is fragile.


    Enjoy, Have FUN! H.Merijn
      I use use Text::CSV; yes,talking to the provider of the file!thanks