in reply to To decode URL-decoded UTF-8 string.

Hello nikolay,

Is this working for you?

#!/usr/bin/perl
use strict;
use warnings;

use Encode;
use URI::Escape;

binmode STDOUT, ":utf8";

my $in = "%d0%be%d0%b1/%d1%81%d1%82%d0%b5%d0%bd";
my $text = Encode::decode('utf8', uri_unescape($in));

print $text . "\n";

__END__

$ perl test.pl
об/стен

Update: Some time ago there was a similar question PDF::API2 printing non ascii characters. Although the tittle is not the same check it out it will help to review some information.

Looking forward to your reply, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: To decode URL-decoded UTF-8 string.
by nikolay (Beadle) on Aug 28, 2018 at 10:06 UTC
    No. I have tried that already before. It only changes %-chars to \x-ones.

      Hello again nikolay,

      Then try this (it should work as expected):

      #!/usr/bin/perl
      use utf8;
      use strict;
      use warnings;
      use URI::Escape;
      use feature 'say';
      use Encode qw/ decode /;
      
      binmode STDOUT, ':utf8';
      
      sub decodedUri {
          return decode 'UTF-8', uri_unescape( shift );
      }
      
      say decodedUri('%d0%be%d0%b1/%d1%81%d1%82%d0%b5%d0%bd');
      
      __END__
      
      $ perl test.pl
      об/стен
      

      BR / Thanos

      Seeking for Perl wisdom...on the process of learning...not there...yet!

        Yes, this works! Thank you!

        By the way, for the DeVuan users, the package, that contains the "URI::Escape" module is called as for now "liburi-encode-perl".