CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
parsing html, yet another utf8 problem :(

 



orange
Novice

Jan 17, 2013, 4:56 AM

Post #1 of 2 (612 views)
parsing html, yet another utf8 problem :( Can't Post

I got another problem with utf8, this part:


Code
use HTML::Parse; 
my $p = HTML::Parser->new(
text_h => [\&text_rtn, 'dtext'],
);
$p->utf8_mode( 1 );
$p->parse_file("$file");

sub text_rtn {
foreach (@_) {
progress ( "\tParsed: >$_<\n");
}


doesn't work. It outputs instead of

:(


(This post was edited by orange on Jan 17, 2013, 4:57 AM)


orange
Novice

Jan 17, 2013, 5:14 AM

Post #2 of 2 (606 views)
Re: [orange] parsing html, yet another utf8 problem :( [In reply to] Can't Post

er, I found the solution, need to open file first as utf8:


Code
 open(my $fh, "<:utf8", "foo.html") || die; 
$p->parse_file($fh);



(This post was edited by orange on Jan 17, 2013, 5:15 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives