-
-
Save antic183/619f42b559b78028d1fe9e7ae8a1352d to your computer and use it in GitHub Desktop.
// remove utf-8 BOM from ressource "res" | |
// res.charCodeAt(0) === 0xFEFF | res.charCodeAt(0) === 65279 | |
if (res.charCodeAt(0) === 0xFEFF) { | |
res = res.substr(1); | |
} |
@antic183 I agree. In my deployment tool chain it lends itself to doing this in an ant replaceregexp task. So I go the regex way ;-)
Thanks a whole lot for this. Can be a bit mystifying when you first encounter a problem caused by this char. Excellent solution.
@michabaur yes that's true. Why don't you just use my version. Substring is faster than regular expressions. One line more or less doesn't change anything. In development there are many empty heads who always think they know something better. I don't mean you, but you don't have to look far.
@cescoallegrini Editing office documents with js is a pain in the ass.
@eladkarako I think you dont know what you do.
One has nothing to lose to be friendly or to not be unfriendly.
@ianthedev
I could have phrased the comment to "cescoallegrini" and "eladkarako" more nicely, I agree with you. But it is simply a fact that many developers always think they know something better and this is often unjustified. Whoever gives it out must also be able to take it. And there are also many developers who sell themselves beyond their worth. Unfortunately, I have experienced this too often. In my opinion, the worst thing about it is that false information is shared and beginners learn the wrong thing.
@michabaur yes that's true. Why don't you just use my version. Substring is faster than regular expressions. One line more or less doesn't change anything. In development there are many empty heads who always think they know something better. I don't mean you, but you don't have to look far.
@cescoallegrini Editing office documents with js is a pain in the ass.
@eladkarako I think you dont know what you do.