5
我想在UTF8編碼文本上使用XML :: RAI perl模塊,並且仍然有錯誤,我不太明白...這裏是代碼(它不應該做任何有用的還):「不能解碼帶寬字符的字符串」出現在奇怪的地方
use HTTP::Request;
use LWP::UserAgent;
use XML::RAI;
use Encode;
my $ua = LWP::UserAgent->new;
sub readFromWeb{
my $address = shift;
my $request = HTTP::Request->new(GET => $address);
my $response = $ua->request($request);
return unless $response->code == 200;
return decode("utf8", $response->content());
}
sub readFromRSS{
my $address=shift;
my $content = readFromWeb $address;
my $rai = XML::RAI->parse_string($content);
#this line "causes" the error
}
readFromRSS("http://aktualne.centrum.cz/export/rss-hp.phtml");
#I am testing it on this particular RSS
的錯誤是:
Cannot decode string with wide characters at /usr/lib/perl5/5.8.8/i686-linux/Encode.pm line 166.
我沒有頭緒,如果這是我的錯或XML的錯誤:: RAI。我沒有看到這些寬字符可以在哪裏,如果$內容已經從utf8解碼...
編輯:出於某種原因,我仍然不明白,刪除「解碼」部分實際上解決了問題。