Home: Perl Programming Help: Advanced:
CrLf from textfield



yapp
User

Feb 13, 2002, 5:40 AM


Views: 3710
CrLf from textfield

To test my CGI scripts, I work used windows2000 iis/5.0, IE 5 (windowsxp, iis5.1, IE6 since yesterday)

When I receive text from a <TEXTFIELD></TEXTFIELD> input field, I seams that my CGI script receives CrLf pairs used for line-breaks. I experienced that problem when I applied a split(/\n/, $message) to the message. Nowadays, I use a regexp to convert the data, and then everything works as it should be.

However, I still have some questions:
- Is this an internet standard?
- Or is this is a bug in iis/ie?
- Does this happen elsewhere aswell?

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


fashimpaur
User / Moderator

Feb 13, 2002, 6:47 AM


Views: 3708
Re: [yapp] CrLf from textfield

Boy, we keep meeting everywhere! Okay, here's the skinny. It happens everywhere. Textfield data
from any win32 platform seems to put in \r characters instead of \n characters each time a new line
is required. When looking at the input from that field type, do a s/\r/\n/g; on that parameter. Then
all the remaining times you run the data through regexes it should work as planned.

HTH,

Dennis

$a="c323745335d3221214b364d545".
"a362532582521254c3640504c3729".
"2f493759214b3635554c3040606a0",
print unpack"u*",pack "h*",$a,"\n\n";


Paul
Enthusiast

Feb 13, 2002, 8:07 AM


Views: 3707
Re: [fashimpaur] CrLf from textfield

Or you could just do:

split(/[\r\n]+/, $message)


yapp
User

Feb 13, 2002, 9:20 AM


Views: 3704
Re: [RedRum] CrLf from textfield

Thanks.

As I said, I already do that... But I don't use the \r character. I use the real ascii escape code, since perl makes \n and \r looks like what's the best for the platform the script runs at.

About my original question: does any platform has such problems, which I should handle?

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool