Solved

urlencode/decode function (unescape)

Posted on 1998-10-01
3
3,463 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
Comment Utility
Edited text of question
0
 
LVL 5

Accepted Solution

by:
b2pi earned 50 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

15 Experts available now in Live!

Get 1:1 Help Now