You need to parse each octet back to the number and use this value to get the character, for example:
function bin2String(array) { var result = ""; for (var i = 0; i < array.length; i++) { result += String.fromCharCode(parseInt(array[i], 2)); } return result; } bin2String(["01100110", "01101111", "01101111"]);
Edit: Yes, your current string2Bin can be written more briefly:
function string2Bin(str) { var result = []; for (var i = 0; i < str.length; i++) { result.push(str.charCodeAt(i).toString(2)); } return result; }
But, looking at the documentation-related one, I think the setBytesParameter method expects the blob array to contain decimal numbers, not a bit string, so you can write something like this:
function string2Bin(str) { var result = []; for (var i = 0; i < str.length; i++) { result.push(str.charCodeAt(i)); } return result; } function bin2String(array) { return String.fromCharCode.apply(String, array); } string2Bin('foo');
CMS Jul 07 2018-10-07T00: 00-07
source share