Search code examples
phplinefeed

PHP: Is it ok to replace \r\n with \n?


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?


Solution

  • That sounds like a reasonable things to do...