Corail Numérique
vendredi, avril 26, 2013
How to convert an arraybuffer to string in javascript
arrayBufferToString : function (arrayBuffer) {
var binary_string = '';
bytes = new Uint8Array(arrayBuffer);
for (var i = 0; i < bytes.byteLength; i++) {
binary_string += String.fromCharCode(bytes[i]);
}
return binary_string;
},
XMLHttpRequest send binary data
XMLHttpRequest.prototype.binarySend = function(string) {
var bytes = Array.prototype.map.call(string, function(c) {
return c.charCodeAt(0) & 0xff;
});
this.send(new Uint8Array(bytes).buffer);
Articles plus récents
Articles plus anciens
Accueil
Inscription à :
Articles (Atom)