문제

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?

도움이 되었습니까?

해결책

That sounds like a reasonable things to do...

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top