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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Carraige Returns

Status
Not open for further replies.

SlykFX

Programmer
Oct 12, 2002
76
GB
I have a form that uses a textarea input.

when the form gets submitted i want to change the windows carriage returns in an html break

i know i need to use a search and replace but im not sure what im looking for

i currently have:
$discription = $form{'discription'};
$discription =~ s/???/<br>/g;

please help me change those question marks to something useful I can't be bothered to have a sig!
 
&quot;???&quot; should be &quot;\r\n&quot; ______________________________________________________________________
TANSTAAFL!
 
inserting the \r\n didnt work the results still returned with the carriage returns in them

ive just checked what the form sends when i use GET instead of POST and the newlines are sent as %0D%0A

i did the search and replace before any of the results get parsed through all my form value handling stuff

For reference my new code is now

Code:
if ($ENV{'REQUEST_METHOD'} eq &quot;GET&quot;) 
{
  $request = $ENV{'QUERY_STRING'};
}
elsif ($ENV{'REQUEST_METHOD'} eq &quot;POST&quot;) 
{
  read(STDIN, $request,$ENV{'CONTENT_LENGTH'}) 
} 
@parameter_list = split(/&/,$request);
foreach (@parameter_list) 
{
  ($name, $value) = split(/=/);
  $value =~ s/%0D%0A/<br>/g;
  $name =~ s/%0D%0A/<br>/g;
  $value =~ s/\+/ /g;
  $name =~ s/\+/ /g;
  $value =~ s/%([0-9A-F][0-9A-F])/pack(&quot;c&quot;,hex($1))/ge;
  $name =~ s/%([0-9A-F][0-9A-F])/pack(&quot;c&quot;,hex($1))/ge;
  if (!defined $passed{$name})
  {
    $form{$name} = $value;
  }
  else 
  {
    $form{$name} .= &quot;:$value&quot;;
  }
}
I can't be bothered to have a sig!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top