[ic] Cleaning carriage returns etc.

quzax me@quzax.com
Thu, 12 Apr 2001 23:00:47 -0600


Assuming that you are cleaning "data which contains tabs & new lines" and
not "tab delimited data" I would just replace the tabs & new lines with html
tags with a little perl similar to:

$textareadata =~ s/\t/\&nbsp\;\&nbsp\;\&nbsp\;/g;     #replace tabs (\t)
with 3 spaces
$textareadata =~ s/\n/<br>/g;     #replace newline with a <br>

You may also want to replace &,<,>," & probably a few others I can't think
of. But you do need to make sure you do your replacements in the right order
or else replacing '&' with '&amp;' will make your '&nbsp;' into
'&amp;nbsp;'.

$textareadata =~ s/\&/\&amp\;/g;    # replace & with &amp;
$textareadata =~ s/\"/\&quot\;/g;    # replace " with &quot;
$textareadata =~ s/\t/\&nbsp\;\&nbsp\;\&nbsp\;/g;     #replace tabs (\t)
with 3 spaces
$textareadata =~ s/</\&lt\;/g;     # replace < with &lt;
$textareadata =~ s/>/\&gt\;/g;     # replace > with &gt;
$textareadata =~ s/\n/<br>/g;     #replace newline with a <br>

I may have escaped too many or too little characters in the above.

--
quzax
me@quzax.com
--
A KGB keyboard has no escape key.



----- Original Message -----
From: "Rene Hertell" <rene@hertell.com>
To: "Interchange-Users" <interchange-users@minivend.com>
Sent: Thursday, April 12, 2001 4:11 PM
Subject: [ic] Cleaning carriage returns etc.


Hi list,

I bumped in problems with a field that I clean from tabs, carriage returns
etc. The formatting afterwards is not really what I want when I display the
value somewhere...

Can someone help me with some tips in what way <textarea> fields should be
collected and stored (eg. tab replaced with 3 spaces etc.), in other words:
what is safe to store in a tab-delimited file and what is not, and how
should these characters be replaced/removed.

Regards, René


_______________________________________________
Interchange-users mailing list
Interchange-users@lists.akopia.com
http://lists.akopia.com/mailman/listinfo/interchange-users