tags:

views:

151

answers:

2

I have a form with a textarea and a JS character counter. Yet the backend script claims that the strlen of the message is longer than the JS character counter claimed. The reason for this, I have discovered, is that the backend sees every newline character as \r\n which is two characters.

Can I simply have it do a str_replace("\r\n","\n",$input)? Or will this cause windows-users to see the string all on one line? Is there any reason why I should not do this?

+1  A: 

When storing it is acceptable to only use \n. You may choose to expand it when extracting later. Note that a \r in places other than just before a \n may hold other significance and so you should not just blindly remove all instances of it.

Ignacio Vazquez-Abrams
A: 

That sounds like a reasonable things to do...

psychotik