Cannot receive "\uffff" correctly in Firefox 5 or before
When I attempt to send a unicode character like \uffff, the encoding breaks.
I haven't read the spec, but possibly it doesn't support multibyte characters. To encode a string to a bytestring in JavaScript, you need to do unescape(encodeURIComponent(data)). Likewise, to decode it, you need to do decodeURIComponent(escape(data)).
http://code.google.com/p/websocket-sample/wiki/Tips ("not to use encodeURIComponent" section)
I don't think you understand what my code does. It doesn't add any bloat to the string itself, it just turns it into a bytestring. I'm not only using encodeURIComponent, which is what that tip says not to do.
I think the article says that "WebSocket supports UTF-8 characters, so you don't need any encoding". This is true for web-socket-js too. Problem here is that, web-socket-js internally use encodeURIComponent/decodeURIComponent to pass data from JS to Flash, but decodeURIComponent(encodeURIComponent("\uffff")) != "\uffff" in Firefox. This looks bug of Firefox to me. escape/unescape actually works correctly for "\uffff" but it looks escape/unescape has another issue: https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Functions#escape_and_unescape_Functions
FIrefox decodes percent-encoded U+FFFE and U+FFFF to U+FFFD. Discussion bug is here: https://bugzilla.mozilla.org/show_bug.cgi?id=520095
see
https://bugzilla.mozilla.org/show_bug.cgi?id=686312
which is fixed in FF9
Thanks for the information. So far we still use Flash implementation for Firefox, and the issue is implementation of encodeURIComponent/decodeURIComponent, which I'm not sure is also fixed by the change. Anyway we will use MozWebSocket when available #87 , so it will be fixed once we do that.