From b51cbf6c069e57f703a1872dd520140db14a9e5a Mon Sep 17 00:00:00 2001 From: Victor Costan Date: Thu, 13 Sep 2012 02:08:20 -0300 Subject: [PATCH] Fix btoa to match browser implementations Test case: btoa(String.fromCharCode(252)) should return "/A==" --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 8bfc1ad..350cd4b 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ "use strict"; function btoa(str) { - return new Buffer(str, 'utf8').toString('base64'); + return new Buffer(str, 'binary').toString('base64'); } module.exports = btoa;