Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Convert a base64 string into a binary Uint8 Array

View gist:1032746
1 2 3 4 5 6 7 8 9 10 11 12 13 14
var BASE64_MARKER = ';base64,';
 
function convertDataURIToBinary(dataURI) {
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = window.atob(base64);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
 
for(i = 0; i < rawLength; i++) {
array[i] = raw.charCodeAt(i);
}
return array;
}
PAEz commented

Thanks, you made my day.

Owner

Glad for it!

Thanks for this script!

Small nit: your "i" needs a "var" declaration to avoid it becoming global...

Thanks Buddy :)

:) nice!

fantastic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.