Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^4: PDF::API2 printing non ascii characters

by Anonymous Monk
on Mar 13, 2018 at 16:22 UTC ( #1210834=note: print w/replies, xml ) Need Help??

in reply to Re^3: PDF::API2 printing non ascii characters
in thread PDF::API2 printing non ascii characters

I'm scratching my head now with the code below:

#sometext is a web input my $line = uri_escape($sometext); # $line prints $VAR1 = 'Hello%20%CF%89%20%E2%88%9E'; $line = uri_unescape($line); # $line prints Hello ω ∞
instead of Hello ω ∞

What am I missing?

Replies are listed 'Best First'.
Re^5: PDF::API2 printing non ascii characters
by thanos1983 (Vicar) on Mar 14, 2018 at 09:44 UTC

    Hello Anonymous Monk,

    Try something like that:

    use utf8;
    use strict;
    use warnings;
    use URI::Escape;
    use feature 'say';
    use Encode qw/ decode /;
    binmode STDOUT, ':utf8';
    sub nonDecodedUri {
        return uri_unescape( shift );
    sub decodedUri {
        return decode 'UTF-8', uri_unescape( shift );
    say nonDecodedUri('Hello%20%CF%89%20%E2%88%9E');
    say decodedUri('Hello%20%CF%89%20%E2%88%9E');
    $ perl
    Hello ‰ ˆž
    Hello ω ∞

    Notice the comments of fellow Monk vr on his answer above.

    Hope this helps, BR.

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

      Thank you so much. Really appreciate all the solutions here :)))

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1210834]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2018-03-18 04:54 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (228 votes). Check out past polls.