JSFiddle - React, Tailwind, and code Playground

by mowglisanu

JavaScript

var xhr_object = new XMLHttpRequest();
xhr_object.overrideMimeType('text/plain; charset=x-user-defined');
xhr_object.open('POST', '/echo/html/', false);
var ab = new Uint8Array(1);
ab[0] = 255;
var form = new FormData();
form.append('html', 'ÿ');
xhr_object.sendAsBinary(form);
if(xhr_object.status == 200){
    var responseText = xhr_object.responseText;
    var responseTextLen = responseText.length;
    var binary = ''
    for (var j = 0; j < responseTextLen; j+=1) {
        binary += String.fromCharCode(responseText.charCodeAt(j) & 0xff)
    }   
    base64Image = 'data:image/jpeg;base64,' + window.btoa(binary);
}