Res: Res: Parsing of undecoded UTF-8 will give garbage when decoding entities

[email protected] (Bianca Shibuya)
Newsgroups perl.macosx
Message-ID <[email protected]>
The warning is still there.

The code is below:

  my $page = get($URL);

   $te = HTML::TableExtract->new(); 
   $te->parse($page); # parse() returns an arrayref containing each table encountered
   
   $cont_table = 0;
   foreach $ts ($te->tables) {      ## foreach $ts ($te->tables)
      if ($cont_table == 1) {       ## Reporter's name is stored in Table 1 Row 0
          $cont_row = 0;
          foreach $row ($ts->rows) {
             if ($cont_row == 0) {
                 if(!defined @$row[7]) {
                    $reporter = '';}
                 else {
                     $reporter = encode_utf8(@$row[7]);}
                 last;
             }
             $cont_row++;
          }
      
      }
.........
  }

The error is at this line: $te->parse($page); but as it is an array.. I applied the encode_utf8 at its strings.
I have applied decode too (according to "To convert an input string of bytes which represents a UTF-8 string, into Perl's internal string format, we DECODE the byes to from UTF-8") but the error persists.

Any help is welcome!
Thanks in advance.

Bianca


----- Mensagem original ----
De: Bianca Shibuya <[email protected]>
Para: [email protected]; [email protected]
Enviadas: Sábado, 27 de Setembro de 2008 20:08:22
Assunto: Res: Parsing of undecoded UTF-8 will give garbage when decoding     entities

Ow.. that is right. Thank you! I will try it.




----- Mensagem original ----
De: "[email protected]" <[email protected]>
Para: Bianca Shibuya <[email protected]>; [email protected]
Cc: [email protected]
Enviadas: Sábado, 27 de Setembro de 2008 19:58:27
Assunto: Re: Parsing of undecoded UTF-8 will give garbage when decoding     entities

You have to pass strings to encode_utf8, so call it after converting the tables to strings, whenever that occurs. What you tried,  encode_utf8($te->parse($page)), is passing encode_utf8 an arrayref, which cannot work. The other things you tried are incorrect.
-pc

>Hi people!
>It is me again. =(
>
>I am having this warning: Parsing of undecoded UTF-8 will give garbage when decoding entities.
>
>I have read that the solution is: The solution is to use the Encode::encode_utf8() on the data before feeding it to the $p->parse().
>
>Ok then use the function encode_utf8(). But how?
>
>I have this piece of code:
>
>  my $page = get($URL);
>
>   $te = HTML::TableExtract->new();
>   $te->parse($page);       # parse() returns an arrayref containing each table encountered
>
>   $cont_table = 0;
>   foreach $ts ($te->tables) {
>  (...)
>
>  I tried to use: encode_utf8($te->parse($page));
>
>  or: $te = encode_utf8(parse($page));
>  or: $te-> encode_utf8(parse($page));
>  or $var->encode_utf8(parse($page)); and where there is $te->tables, place it by $var->tables
>
>You can see I dont know how to use it   X-|
>
>Help me! Thank you.
>
>Bianca
>
>
>      Novos endereços, o Yahoo! que você conhece. Crie um email novo com a sua cara @ymail.com ou @rocketmail.com.
>http://br.new.mail.yahoo.com/addresses
>


      Novos endereços, o Yahoo! que você conhece. Crie um email novo com a sua cara @ymail.com ou @rocketmail.com.
http://br.new.mail.yahoo.com/addresses



      Novos endereços, o Yahoo! que você conhece. Crie um email novo com a sua cara @ymail.com ou @rocketmail.com.
http://br.new.mail.yahoo.com/addresses
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.