Solved

urlencode/decode function (unescape)

Posted on 1998-10-01
3
3,471 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

943 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

Need Help in Real-Time?

Connect with top rated Experts

3 Experts available now in Live!

Get 1:1 Help Now