Reputation: 387
I'm new in perl, and if i use the following code:
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};
and as result I become: Tornyosi+m%C5%B1sor
How can decode (or what module should be using) for readable string Tornyosi műsor ?
Thank you.
Upvotes: 2
Views: 276
Reputation: 242343
URI::Encode or URI::Escape will handle the %
encoded characters. The +
to space you'll have to do yourself:
#!/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";
or
#!/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";
You might need to decode the strings if you want to output to an io layer with encoding. See Encode.
Upvotes: 3