ed111 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to translate URL encoded strings which were originally in Arabic. Any suggestions as to a good way to approach this? I requested BAMA from UPenn as per another post but got no response from UPenn.

Replies are listed 'Best First'.
Re: URL translation
by ikegami (Patriarch) on Jun 22, 2009 at 17:28 UTC
    You said translate. Did you mean decode? URI will handle the URI decoding, but you'll have to reverse the character decoding yourself. (URI can't do it since it doesn't know which character encoding was used.)
    use URI qw( ); my @segments = URI->new($url)->path_segments(); utf8::decode($_) for @segments;

    URI, utf8

    Update: Added missing decode.

Re: URL translation
by Utilitarian (Vicar) on Jun 22, 2009 at 17:29 UTC
    Hi Ed, When you say URL encoded, you do know that %nnnn URL encoding is Unicode chr(0xnnnn), Just checking.

    Looking back over your previous question, this gives you the Unicode words you spoke of, as to human language translation engines in Perl, I'm afraid I can't answer that aspect of your problem :(