Skip to content
This repository has been archived by the owner on Nov 4, 2019. It is now read-only.

fix The "Unicode Problem" in utf-16 #59

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions extension/js/background_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,15 @@ function setOrangeIcon() {
}

function getBase64FromArrayBuffer(responseData) {
var uInt8Array = new Uint8Array(responseData),
i = uInt8Array.length,
binaryString = new Array(i);
while (i--)
{
binaryString[i] = String.fromCharCode(uInt8Array[i]);
}
var data = binaryString.join(''),
base64 = window.btoa(data);
var uInt8Array = new Uint8Array(responseData);
var str = new TextDecoder().decode(uInt8Array);

return base64;
function b64EncodeUnicode(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
return b64EncodeUnicode(str)
}

// returns an object from the xhr.getAllReponseHeaders text-only version
Expand Down