use v5.22; use warnings; use Devel::Dwarn; use Cpanel::JSON::XS; use Encode qw/ decode encode /; use Text::CSV_XS; my $csv = Text::CSV_XS->new({ binary => 1, auto_diag => 1 }); while (my $line = ) { say "Before=".$line; my $string = encode('UTF8', $line); my $x = $csv->parse($string); warn $x if !$x; my @data = $csv->fields; Dwarn \@data; my $structure = encode_json(\@data); } __DATA__ IR_Choix_0092.tif,C,psi,,"Wild pansy (Viola tricolor), 19th century illustration","19th-century hand painted illustration of wild pansy, heart<92>s ease, or love in idleness (Viola tricolor) flower by Pierre-Joseph Redoute (1759-1840). Published in Choix Des Plus Belles Fleurs, Paris (1827).",N/A,"Pansy, pansies, wild, Viola tricolor, 19th century, painted, Engraving, illustration, nobody, no-one, flower, artwork, Pierre Joseph redoute, bloom, blossom, botanical, botanist, bud, flora, floral, history, historic, horticulture, leaves, petal, petals, plant, vintage, watercolor, flower head, painting, stem, victorian style, botanic, flowers, plants, Botany",,C,Fl,N/A,,,,^M