Solved

Killing passed text...

Posted on 2000-03-21
7
117 Views
Last Modified: 2010-03-05
This should be simple: is there a way to supress the output of the special escape characters in Perl?  In other words, if the user enters something like:

"I like to eat cheese!"

Can I keep it from being passed as:

"I+like+to+eat+cheese%21"?  

I need to output the text back to HTML, and it's obviously no good to me like this.  Do I just have to do an s///?  Or is there an easier way?
0
Comment
Question by:Raydot
7 Comments
 
LVL 4

Expert Comment

by:binkzz
ID: 2639788
You can't pass it any other way, but you can decode it by using two regular expressions:

$key=~s/\+/ /g;
$key=~s/%([0-9a-fA-f]{2})/pack("c",hex($1))/ge;

Binkzz
0
 
LVL 84

Expert Comment

by:ozo
ID: 2640105
why not pack("H*",$1)?
0
 
LVL 4

Expert Comment

by:binkzz
ID: 2640126
It works and doesn't particulary slow down the system
0
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!

 
LVL 16

Accepted Solution

by:
maneshr earned 50 total points
ID: 2640189
if you have the URI::Escape PERL module, try this....

if you dont, i would suggest that you install the same from www.cpan.org.

its very useful, since you dont have to worry about all the special characters to escape and unescape.

==============escape.pl
#!/usr/local/bin/perl

use URI::Escape;

$str="I like to eat cheese!";

print "Original string ",$str,"\n";
$safe = uri_escape($str);
print "After Escaping ",$safe,"\n";

$str  = uri_unescape($safe);
print "After Un-Escaping ",$str,"\n";
0
 
LVL 4

Expert Comment

by:binkzz
ID: 2640235
Can I just find out what's actually wrong with my solution?

Binkzz
0
 
LVL 3

Author Comment

by:Raydot
ID: 2640628
Who said there was anything wrong with your solution?  I think man and ozo are just offering alternatives.

I'll have to check for that URI::Escape module...Ozo, I don't really understand your pack solution.  Thanks!
0
 
LVL 3

Author Comment

by:Raydot
ID: 2810997
Did y'all think I forgot about this question?  Thanks for all your help!
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

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 …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…

809 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