Skip to content

Commit

Permalink
Changed String.charCodeAt(S[i]) into S.charCodeAt(i), now works with …
Browse files Browse the repository at this point in the history
…Safari and

Chrome. Thanks to tonyrog for the patch.
  • Loading branch information
rustyio committed Dec 30, 2009
1 parent 0a341fe commit ef149b1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions bert.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ BertClass.prototype.decode_inner = function (S) {
case this.NIL:
return this.decode_nil(S);
default:
throw ("Unexpected BERT type: " + String.charCodeAt(Type));
throw ("Unexpected BERT type: " + S.charCodeAt(0));
}
};

Expand Down Expand Up @@ -395,9 +395,9 @@ BertClass.prototype.int_to_bytes = function (Int, Length) {
// of the supplied string.
BertClass.prototype.bytes_to_int = function (S, Length) {
var isNegative, i, n, Num = 0;
isNegative = (String.charCodeAt(S[0]) > 128);
isNegative = (S.charCodeAt(0) > 128);
for (i = 0; i < Length; i++) {
n = String.charCodeAt(S[i]);
n = S.charCodeAt(i);
if (isNegative) {
n = 255 - n;
}
Expand Down Expand Up @@ -440,10 +440,10 @@ BertClass.prototype.bignum_to_bytes = function (Int) {
// Encode a list of bytes into an Erlang bignum.
BertClass.prototype.bytes_to_bignum = function (S, Count) {
var isNegative, i, n, Num = 0;
isNegative = (String.charCodeAt(S[0]) === 1);
isNegative = (S.charCodeAt(0) === 1);
S = S.substring(1);
for (i = Count - 1; i >= 0; i--) {
n = String.charCodeAt(S[i]);
n = S.charCodeAt(i);
if (Num === 0) {
Num = n;
}
Expand Down Expand Up @@ -475,7 +475,7 @@ BertClass.prototype.pp_bytes = function (Bin) {
if (s !== "") {
s += ",";
}
s += "" + String.charCodeAt(Bin[i]);
s += "" + Bin.charCodeAt(i);
}
return "<<" + s + ">>";
};
Expand Down

0 comments on commit ef149b1

Please sign in to comment.