mathiasbynens / windows-1252

A robust JavaScript implementation of the windows-1252 character encoding as defined by the Encoding Standard.
https://mths.be/windows-1252
MIT License
45 stars 21 forks source link

Error not being descriptive #1

Open tomasdev opened 9 years ago

tomasdev commented 9 years ago

throw Error(); could be improved with some message for devs, like "I couldn't encode the char XX because of the mapping wasn't found"

I'm getting into that line with codePoint = 8706 and mode not being set (therefore defaulting to fatal) while trying to .encode().

I have no idea how to fix it, buuuut I'd be more than happy to PR otherwise. I've read https://mathiasbynens.be/notes/javascript-encoding but I get lost in // “Return a byte whose value is pointer + 0x80.” anyway :|

Update: I see the list is coming from https://encoding.spec.whatwg.org/index-windows-1252.txt - But my newbie question would be... how does windows-1252 show any character outside that list and above 0x7F ? I remember seeing the character this issue is about (∂) on windows as well.

(Yay first issue here!)

Prinzhorn commented 1 month ago

Well, almost ten years later this just bit us. We had a bug in our error handling that was causing errors without a message to trigger an endless recursion resulting in a RangeError masking the original error in windows-1252. Even after fixing it the error is still not descriptive, it just says "Error: Error". Luckily the stack pointed to windows-1252 and here I am.