Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Text::CSV encoding parse()

by haukex (Chancellor)
on Aug 13, 2019 at 18:05 UTC ( #11104405=note: print w/replies, xml ) Need Help??


in reply to Text::CSV encoding parse()

some accented characters are showing up in the resulting web page as black diamond question marks

Are you sure you've also set your output filehandles to the correct encoding, and have specified that encoding in the HTML? Please provide a Short, Self-Contained, Correct Example.

To debug the input end of the process, see my suggestions at Re: Parsing Problems.

Replies are listed 'Best First'.
Re^2: Text::CSV encoding parse()
by slugger415 (Monk) on Aug 13, 2019 at 18:45 UTC

    Hi, yes I'm using the CGI module and have it properly set:

    print $q->header(-charset    => 'utf-8');

    And as mentioned if I don't use Text::CVS the characters display correctly.

      Hi, yes I'm using the CGI module and have it properly set: print $q->header(-charset => 'utf-8'); And as mentioned if I don't use Text::CVS the characters display correctly.

      Ok, but I'm sorry, there still isn't enough information to answer your question - have another look at my reply above, plus the links therein.

        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.

      That means that you are declaring to the browser that your output is UTF-8. Is it actually UTF-8?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11104405]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2019-09-19 04:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (239 votes). Check out past polls.

    Notices?