changeset 92:bcd2e32cfabb

fixed the user name encoding issue.
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 26 Oct 2008 22:56:16 +0800
parents 53c87400183f
children 73f0a1cafc23
files Ikariam.pm
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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;
         }
     }