# HG changeset patch # User "Rex Tsai " # Date 1225032976 -28800 # Node ID bcd2e32cfabb21185629bdc3187edf00fc59f087 # Parent 53c87400183f9ce27f72ebcf3b079979a996a9f4 fixed the user name encoding issue. diff -r 53c87400183f -r bcd2e32cfabb Ikariam.pm --- a/Ikariam.pm Sun Oct 26 22:14:15 2008 +0800 +++ b/Ikariam.pm Sun Oct 26 22:56:16 2008 +0800 @@ -68,7 +68,7 @@ return () if($result->size() == 0); foreach ( @$result ) { # $_ is XML::LibXML::Element, XML::LibXML::Node - my $literal = $_->to_literal() , "\n"; + my $literal = $_->to_literal(); utf8::encode($literal); # warn $_->toString(1) , "\n"; return $literal unless wantarray; @@ -162,20 +162,20 @@ foreach my $tr ( @$result ) { my %user; - my $href = $tr->find('//td[@class="action"]/a/@href'); + $extractor->{doc} = $tr; + my $href = $extractor->find('//td[@class="action"]/a/@href'); if($href =~ /index\.php\?view=sendMessage&with=(\d+)&oldView=highscore/) { $user{'id'} = $1; - $user{'name'} = $tr->find('//td[@class="name"]/text()'); - $user{'ally'} = ($tr->find('//td[@class="allytag"]/a/text()'))[0]->to_literal(); - my $allyHref = $tr->find('//td[@class="allytag"]/a/@href'); + # $user{'name'} = $extractor->find('//td[@class="name"]'); + $user{'name'} = $user; + + $user{'ally'} = $extractor->find('//td[@class="allytag"]/a/text()'); + my $allyHref = $extractor->find('//td[@class="allytag"]/a/@href'); if($allyHref =~ /\?view=allyPage&allyId=(\d+)/) { $user{'allyId'} = $1; } - $user{$type} = $tr->find('//td[@class="score"]/text()'); + $user{$type} = $extractor->find('//td[@class="score"]/text()'); $user{$type} =~ s/,//g; - - # converting data type and encoding. - foreach(keys(%user)) { utf8::encode($user{$_}); } $users{$user{'id'}} = \%user; } }