in reply to Re^3: Text::CSV encoding parse()
in thread Text::CSV encoding parse()
Hello, ok here's as short and succinct a sample as I can create.
use Text::CSV; use CGI; my($row) = "search/¿Cuales son las partes de una cadena de conexión??s +cope|ids_jdbc_011.htm|0|1|1|0"; my $csv = Text::CSV->new ({ binary => 1, sep_char => "|" }); my $q = new CGI; # print the HTML header and start html print $q->header; print $q->start_html; # first, print $row as is print $q->p("ROW: $row"); # next, parse with $csv $csv->parse($row); my @els = $csv->fields; # print the first field # this displays the black diamond ? symbol for ¿ and ó print $q->p("CSV Parse, field 0:",$els[0]); # split instead my(@splits) = split('\|',$row); # print the first element in @splits. # As noted, this one displays properly in the browser. print $q->p("split 0:", $splits[0]); print $q->end_html; exit;
thanks
======================
UMM, update, when I actually ran the above in my http server I got the opposite results, but with weird errors.
ROW: search/¿Cuales son las partes de una cadena de conexión??scope| +ids_jdbc_011.htm|0|1|1|0 CSV Parse, field 0: search/¿Cuales son las partes de una cadena de con +exión??scope split 0: search/¿Cuales son las partes de una cadena de conexión??sc +ope
Paint me confused.
In the real script, $row is coming from a @sorted_array from an SQL query. This is getting confusing so maybe I should withdraw my question.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: Text::CSV encoding parse()
by haukex (Bishop) on Aug 14, 2019 at 19:55 UTC | |
by slugger415 (Monk) on Aug 14, 2019 at 21:41 UTC | |
by haukex (Bishop) on Aug 15, 2019 at 06:43 UTC | |
by Tux (Abbot) on Aug 15, 2019 at 07:53 UTC | |
by haukex (Bishop) on Aug 15, 2019 at 08:26 UTC | |
by slugger415 (Monk) on Aug 16, 2019 at 18:35 UTC | |
by haukex (Bishop) on Aug 17, 2019 at 06:47 UTC | |
| |
by jcb (Vicar) on Aug 14, 2019 at 23:16 UTC | |
Re^5: Text::CSV encoding parse()
by choroba (Archbishop) on Aug 14, 2019 at 19:35 UTC | |
by slugger415 (Monk) on Aug 14, 2019 at 20:50 UTC |
In Section
Seekers of Perl Wisdom