Solved

urlencode/decode function (unescape)

Posted on 1998-10-01
3
3,477 Views
Last Modified: 2012-06-22
I have urlencoded data (in a database). Retrieving the data is no problem. I wonder if there is an easy way to decode the data. I can write my own function (that is no problem) but it seems likely to me that perl has an inbuilt function for this (which does the same as unescape in javascript).

How do I easily urldecode in perl.

I have found:

use URI::Escape;
and then I can use the function "uri_unescape()", but it does not convert "+" to space. (javascript unescape does that too).
0
Comment
Question by:sybe
  • 2
3 Comments
 
LVL 28

Author Comment

by:sybe
ID: 1205056
Edited text of question
0
 
LVL 5

Accepted Solution

by:
b2pi earned 50 total points
ID: 1205057
I'm not sure why the + should be converted to a ' '.  It's not
mentioned in RFC 1630.  However, should you want to do this manually,
you should do it _before_ passing it to uri::uri_unescape i.e.

$data =~ s/([^\\])\+/$1 /g;
$data = uri_unescape($data);

0
 
LVL 28

Author Comment

by:sybe
ID: 1205058
It works (but so did the thing I wrote).
The encoding from " " to "+" was done by ASP/VBScript. What I was really looking for was one function to do it all, but that probably is not present in perl.
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question