happysailingdude wrote:
> hi guys,
>
> i am taking user input from a textarea in a form and
saving that in my db.
>
> as we all know when one does that the whitespace is sent
from the browser to
> the server but from there on it can get 'lost'
>
Actually, unless something unusual is going on in your
system, the white
space is not 'lost'. Most likely it is right there in the
database
where it is supposed to be.
The issue here, generally, is to understand the technologies
being used
and how they function. The primary one here is the HTML
standard that
says ALL white space (spaces, tabs, newlines, carriage
returns, etc.) is
collapsed into a single space character.
So the whitespace is not getting lost, it is getting ignored
according
to the standard specification of the technology being used.
In fact if
one where to view the source in the browser one would see all
the white
space that is being ignored by the browser as it is designed
to do.
The first way around this is to use the features of the
technology
designed to work with this. In HTML that is the
<pre>...</pre> and
<code>...</code> tags. CFML adds functions such
as htmlEditFormat() and
htmlCodeFormat() to also work with this type of data. Beyond
this you
can role your own solution to display the received data in a
desired format.
Dan's suggestion is that you do not do any transformations on
the data
going into the database, because this locks you into a single
format.
If one just stores the data as is in the database, and then
do the
transformation to the desired format at display time, one can
then
create different displays for different technologies and
purposes from
the same data.