From 767ab55060ac32fde1268881a2947e943591cee8 Mon Sep 17 00:00:00 2001 From: Richard Warburton Date: Tue, 8 Sep 2015 22:11:44 +1200 Subject: [PATCH 1/2] Fix binaryStringToUtf8 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 089aefb..a8d04ed 100644 --- a/index.js +++ b/index.js @@ -25,7 +25,7 @@ function utf8ToBase64(str) { function binaryStringToUtf8(binstr) { var escstr = binstr.replace(/(.)/g, function (m, p) { - var code = p.charCodeAt(p).toString(16).toUpperCase(); + var code = p.charCodeAt(0).toString(16).toUpperCase(); if (code.length < 2) { code = '0' + code; } From 8e5c528f55a9c8fa9a88400c9846ee4ce2ccbfeb Mon Sep 17 00:00:00 2001 From: Richard Warburton Date: Tue, 8 Sep 2015 22:13:30 +1200 Subject: [PATCH 2/2] Fix type mismatch warning with Closure Compiler --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index a8d04ed..abc9099 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ function utf8ToBinaryString(str) { // replaces any uri escape sequence, such as %0A, // with binary escape, such as 0x0A var binstr = escstr.replace(/%([0-9A-F]{2})/g, function(match, p1) { - return String.fromCharCode('0x' + p1); + return String.fromCharCode(parseInt(p1,16)); }); return binstr;