Skip to content

Commit

Permalink
Fixed a nasty IE bug where it's unable to parse the unicode charactur…
Browse files Browse the repository at this point in the history
…e when it's

looked up using data[0]. It will return undefined instead the actual char.

But luckly charAt does return the correct characture
  • Loading branch information
3rd-Eden committed Jul 9, 2011
1 parent f41d213 commit 34ab001
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,17 @@
*/

parser.decodePayload = function (data) {
if (data[0] == '\ufffd') {
// IE doesn't like data[i] for unicode chars, charAt works fine
if (data.charAt(0) == '\ufffd') {
var ret = [];

for (var i = 1, length = ''; i < data.length; i++) {
if (data[i] == '\ufffd') {
if (data.charAt(i) == '\ufffd') {
ret.push(parser.decodePacket(data.substr(i + 1).substr(0, length)));
i += Number(length) + 1;
length = '';
} else {
length += data[i];
length += data.charAt(i);
}
}

Expand Down

0 comments on commit 34ab001

Please sign in to comment.