changeset 110:279a000eb3b0

fixed encoding issue of LibXML
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Wed, 29 Oct 2008 17:49:08 +0800
parents d3bece9b06b2
children 8155f9328396
files Ikariam.pm
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Ikariam.pm	Wed Oct 29 15:56:04 2008 +0800
+++ b/Ikariam.pm	Wed Oct 29 17:49:08 2008 +0800
@@ -41,7 +41,7 @@
 sub parse {
     my ($self, $content) = @_;
     my $string;
-    my $parser = XML::LibXML->new('1.0','utf-8');
+    my $parser = XML::LibXML->new('1.0','UTF-8');
 
     if($self->{gzip} == 1) {
         gunzip \$content => \$string
@@ -50,7 +50,7 @@
         $string = $content;
     }
 
-    $self->{doc} = $parser->parse_html_string ($string, { suppress_errors => 1 });
+    $self->{doc} = $parser->parse_html_string ($string, { suppress_errors => 1, encoding => 'utf-8' });
     return;
 }
 
@@ -188,7 +188,8 @@
         if($href =~ /index\.php\?view=sendMessage&with=(\d+)&oldView=highscore/) {
             $user{'id'} = $1;
             $user{'name'} = $user;
-            $user{'name'} = $extractor->find('//td[@class="name"]');
+            # encoding issue.
+            $user{'name'} = $extractor->find('//td[@class="name"]/text()');
 
             $user{'ally'} = $extractor->find('//td[@class="allytag"]/a/text()');
             my $allyHref = $extractor->find('//td[@class="allytag"]/a/@href');