store text in db with carriage return or with line breaks?

hi all,
I'm curious, is it best to store text copy in a db with carriage returns or with break tags?
I've done both. With carriage returns you don't need to process the values before displaying in a text area form field. With break tags you can write it straight to html... I'm guessing break tags take less physical space to store?
Are there good reasons to go one way or the other?

Who is Participating?
kevp75Connect With a Mentor Commented:
undertandable.  I do some processing before entering too...mainly just to strip ', and garbage html that might get inputted.

efficiency is one thing I don't think any one will ever be able to perfect, as there will always be a better way of doing things.

I use functions, subs, and classes for just about everything, put them all into specific include files (db stuf in, file stuff in, etc..)  and then include them when I need to.  It really is all personal style, like I tried to say in my last post, I try to keep the load split between server and client, that way there isn't too much of a load on either.  Sometimes it works out great and I get very fast loading pages, however sometimes it doesn't work out that wll, and some are slow....but then I try to lessen the load on the client end, and find that it makes matters worse, simply because all the processing the server has to do to process the page....
honestly, I see it more as a preference thing.  I would imagine that storing the data with extra code in it may take up more space, however it is probably minimal, and may be more benficial when it comes to displaying it.

personally, I like to store textual data as is, and then worry about formatting on the page, it may be just me, but, the way I see it is client and server have to do some work to show it to you, my thinking is split the load.  If you store more in the database, the db has more to output (not that I've seen a case like this, but...) potentially bogging down the server.

I guess a good example would be file uploading.  If you upload it directly to the database the db has to store the binary data, then you would code the page to render it.  If you upload the file to a directory, you only really need to store the filename in the db.....
hc0904pcdAuthor Commented:
hi kev,
I like your thinking about filenames for uploads. I like to grab the record id and use that within the filename. Keeps it simple.

With inputting data, I figure I've got to process the data a bit before whacking it into the db, so along with checking for apostrophes and a few other characters I replace carriage returns with break tags at the same time. Only downside is that when I'm in edit mode displaying that text in a text area field I have to then reverse the change and show carriage returns again. But I've got 3 standard functions which speeds it all up, 1 to process data and write to db, 1 to grab from db and display in form fields, and 1 to grab from db and display on html page (with options like get the first paragraph if required for a news snippet, and converting urls to links).

It's nice to see how other people do this.
Would be nice to make my pages more efficient if I could.
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

geteConnect With a Mentor Commented:
I normally apply a general rule: if it's plain text, store as is (with newline characters, e.g. CR/LF/CR+LF). If it's rich/formatted text, store with (HTML) tags. In short, I don't single out line break as an exception to decide whether to use tag or not. If it's supposed to be plain text, it may be used in other medium beside web pages, e.g. in a plain text email message, presented in a another winforms application's label control etc. Having it stored with <br> imho digress from what it's originally intended. Different case if it's a formatted text.
hc0904pcdAuthor Commented:
Good point gete.
I currently treat everything as formatted text as I figure that covers most circumstances I deal with.
hc0904pcdAuthor Commented:
thanks ...
All Courses

From novice to tech pro — start learning today.