paperclip
paperclip copied to clipboard
Add support for leading whitespace
Saw this FIXME comment, figured I could help.
Since the method essentially accepts a byte array, I figured is_ascii_whitespace()
is good enough?
If it's non-ascii, it'd be considerably more effort to remove in the general case, but the specific cases are easy. So it makes sense to me that responsibility for this should fall on the end user.
Added a PR mostly to demonstrate what I mean. It's still needs some tests and checks run.
Another reasonable addition to it could be to add a warning or an error that makes it more clear to the end user that non-ascii support is somewhat limited. If serde
doesn't supports it very well either, then I don't think this is necessary.
I think checking for ascii whitespace only is probably fine for now, as it's better than not doing anything so I've merged it.
For even more improvements, we could also check how serde_json
handles non-ascii whitespace?