carriage return/new line comparison

K

Karthik.S

I have a text area in my webpage where i allow people to format their
data in to multiple paragraphs. I store this data in the database and
display it in a similar textarea to keep the formatting the same.

The javascript i use to construct a xml document of all the changed data
in my webpage compares the data in the textarea to data stored in an xml
data island. Whenever the data has these carriage returns or new line
("\r\n") it always thinks that the data has changed. so

"abcd\r\nefgh" is not equal to "abcd\r\nefgh".....

Any ideas why this may happen.

Regards
 
E

Eric Bohlman

I have a text area in my webpage where i allow people to format their
data in to multiple paragraphs. I store this data in the database and
display it in a similar textarea to keep the formatting the same.

The javascript i use to construct a xml document of all the changed data
in my webpage compares the data in the textarea to data stored in an xml
data island. Whenever the data has these carriage returns or new line
("\r\n") it always thinks that the data has changed. so

"abcd\r\nefgh" is not equal to "abcd\r\nefgh".....

Any ideas why this may happen.

XML parsers normally (hehe!) normalize any combination of CR (usually
represented as \r) and LF (usually represented as \n) in text to a single
LF (\n). So your stored data is probably actually "abcd\nefgh". If that's
the problem, removing any \r's from the textarea data should solve it.
 
K

Karthik.S

Yep. That did the trick.

Thanks a lot.

Eric said:
XML parsers normally (hehe!) normalize any combination of CR (usually
represented as \r) and LF (usually represented as \n) in text to a single
LF (\n). So your stored data is probably actually "abcd\nefgh". If that's
the problem, removing any \r's from the textarea data should solve it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top