Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting url encoded string back to html

Status
Not open for further replies.

maslett

Technical User
Mar 11, 2004
121
GB
Hi all, great forum btw.

I have a textarea input box - when I fill it in as, say:

Code:
line 1

line 2

line 3

my perl script receives it as an url encoded string such as

Code:
line+1%0D%0A%0D%0Aline+2%0D%0A%0D%0Aline+3

This is fine but I need to write it as one record into a mysql database and keep the html formatting, ie.

Code:
line1<br><br>line2<br><br>line3

Have checked the archives but no joy. Am also a bit new to this Perl malarky :)

Cheers,
Matt
 
A fast, dirty routine:
Code:
sub unescape {
  local ($_) = @_;
  tr/+/ /;
  s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
  return $_;
}
 
Thanks guys! Worked a treat.

Was going to ask another dumb question but just remembered the <pre> tag in time - lol

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top