如何使用perl将html字符串解码为readeble格式
我是perl新手,如果我使用以下代码:如何使用perl将html字符串解码为readeble格式,perl,Perl,我是perl新手,如果我使用以下代码: use strict; use warnings; use WWW::YouTube::Info::Simple; my $id = 'aPLnXzjWMZE'; my $yt = WWW::YouTube::Info::Simple->new($id); my $info = $yt->get_info(); print $info->{title}; 结果我变成了:Tornyosi+m%C5%B1sor 如何对可读字符串Tor
use strict;
use warnings;
use WWW::YouTube::Info::Simple;
my $id = 'aPLnXzjWMZE';
my $yt = WWW::YouTube::Info::Simple->new($id);
my $info = $yt->get_info();
print $info->{title};
结果我变成了:Tornyosi+m%C5%B1sor
如何对可读字符串Tornyosi műsor进行解码(或者应该使用什么模块)
谢谢。或将处理%
编码字符。+
到空格,您必须自己执行以下操作:
#!/usr/bin/perl
use warnings;
use strict;
use URI::Encode;
my $encoder = 'URI::Encode'->new;
( my $s = 'Tornyosi+m%C5%B1sor' ) =~ s/\+/ /g;
$s = $encoder->decode($s);
print $s, "\n";
或
如果要使用编码输出到io层,可能需要对字符串进行解码。请参阅。非常感谢。:)@瓦泰,修正了一个错误。
#!/usr/bin/perl
use warnings;
use strict;
use URI::Escape;
( my $s = 'Tornyosi+m%C5%B1sor' ) =~ s/\+/ /g;
my $s = uri_unescape($s);
print $s, "\n";