4

Maybe I'm just being lazy though.

Maybe I'm just being lazy though.

14 comments

Programmer Pro-tip #127: Language depending, Trim() has a parameter override allowing you to trim more than just spaces.

Javascript doesn't have this but you can easily write a method to replace the default trim method so that you can do this.

[–] xyzzy 1 points (+1|-0)

In my worst situation a .trim would haven trimmed all whitespace, but it wasn't used since there was a character limit. Too bad users copied from emails including a few dozen newlines at the end.

Wasn't hard to fix, but hard to find.

Isn't there an encode that automagically strips all that nonsense?

[–] xyzzy 1 points (+1|-0)

There probably is, but IMHO there shouldn't. An encode should encode and nothing else, no sanitizing, no stripping, no fiddling with encoding.

One tool for one thing. Simple input, simple output. Combine them as alias or function or method or whatever your language likes it to be called.