diff --git a/index.js b/index.js index f99fa42..bba7391 100644 --- a/index.js +++ b/index.js @@ -51,7 +51,7 @@ function base64ToUtf8(b64) { function bufferToBinaryString(buf) { var binstr = Array.prototype.map.call(buf, function (ch) { - return '0x' + String.fromCharCode(ch); + return String.fromCharCode(ch); }).join(''); return binstr; @@ -84,48 +84,6 @@ function base64ToBuffer(base64) { return buf; } -// Hex Convenience Functions -, hexToBuffer: hexToBuffer -, bufferToHex: bufferToHex - -function bufferToHex(arr) { - var i; - var len; - var hex = ''; - var c; - - for (i = 0, len = arr.length; i < len; i += 1) { - c = arr[i].toString(16); - if (c.length < 2) { - c = '0' + c; - } - hex += c; - } - - return hex; -} - -function hexToBuffer(hex) { - // TODO use Uint8Array or ArrayBuffer or DataView - var i; - var byteLen = hex.length / 2; - var arr; - var j = 0; - - if (byteLen !== parseInt(byteLen, 10)) { - throw new Error("Invalid hex length '" + hex.length + "'"); - } - - arr = new Uint8Array(byteLen); - - for (i = 0; i < byteLen; i += 1) { - arr[i] = parseInt(hex[j] + hex[j + 1], 16); - j += 2; - } - - return arr; -} - window.Unibabel = { utf8ToBinaryString: utf8ToBinaryString , utf8ToBuffer: utf8ToBuffer