XFileSharing Pro - How to fully encode a URL?

Powerfull XFileSharing version

Moderator: admin

Message
Author
komi
Posts: 161
Joined: Nov 27, 2009 12:41 pm

How to fully encode a URL?

#1 Postby komi » Mar 08, 2010 7:32 am

Hello,

I have to know how to fully encode an url in perl. I temporarily did this with JavaScript, but would like to do it via the script.

Thanks in advance.

mrperl
Posts: 65
Joined: Mar 06, 2010 11:40 am

Re: How to fully encode a URL?

#2 Postby mrperl » Mar 08, 2010 10:38 am

Hi komi.

Depends on what you mean by encoding/escaping and where the
result will be used.

XFS Pro includes a copy of CGI::Simple, so that's one way to encode a url.

Code: Select all

use strict;
use diagnostics;

use lib 'Modules'; # customize this for your XFS Pro installation

use CGI::Simple;

    my $q = new CGI::Simple;
    my $url = 'http://sample.com/file 1.html'; # embedded space
    my $encoded = $q->url_encode($url);
    print $encoded, "\n";


The result is:

Code: Select all

http%3A%2F%2Fsample.com%2Ffile+1.html

Thanks, mrperl.

http://search.cpan.org/dist/CGI-Simple/lib/CGI/Simple.pm

komi
Posts: 161
Joined: Nov 27, 2009 12:41 pm

#3 Postby komi » Mar 08, 2010 11:40 am

Perfect! Thanks.


Return to “XFileSharing Pro”

Who is online

Users browsing this forum: No registered users and 0 guests