RegisterRegister    SearchSearch   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AJAX upload progress bar

File sharing script

File mirror script

Newsletter script
How to fully encode a URL?

 
Post new topic   Reply to topic    SibSoft Ltd Forum Index -> XFileSharing Pro
View previous topic :: View next topic  
Author Message
komi



Joined: 27 Nov 2009
Posts: 159

PostPosted: Mar 08, 2010 7:32 am    Post subject: How to fully encode a URL? Reply with quote

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.
Back to top
View user's profile Send private message
mrperl



Joined: 06 Mar 2010
Posts: 65

PostPosted: Mar 08, 2010 10:38 am    Post subject: Re: How to fully encode a URL? Reply with quote

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:

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:

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

Thanks, mrperl.

http://search.cpan.org/dist/CGI-Simple/lib/CGI/Simple.pm
Back to top
View user's profile Send private message
komi



Joined: 27 Nov 2009
Posts: 159

PostPosted: Mar 08, 2010 11:40 am    Post subject: Reply with quote

Perfect! Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SibSoft Ltd Forum Index -> XFileSharing Pro All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group