closure-library icon indicating copy to clipboard operation
closure-library copied to clipboard

goog.string.trim remove BOM too.

Open vivekimsit opened this issue 9 years ago • 1 comments

I see that the code uses:

return str.replace(/^[\s\xa0]+|[\s\xa0]+$/g, '');

shouldn't we remove the BOM too as they are useless in utf-8:

return str.replace(/^[\s\uFEFF\u00A0]+|[\s\uFEFF\u00A0]+$/g, '');

vivekimsit avatar Jul 18 '16 09:07 vivekimsit

Seems reasonable enough at first glance. I'm having trouble finding useful references describing potential issues stripping BOM. If you want to create a PR, we can test it out internally.

joeltine avatar Jul 18 '16 16:07 joeltine