title: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded
body: <p>I'm trying to Convert data URI to image data but I faced this error:</p>
  
  <blockquote>
    <p>Failed to execute 'atob' on 'Window': The string to be decoded is not
      correctly encoded</p>
  </blockquote>
  
  <p>the function:</p>
  
  <pre><code>function dataURLtoBlob(dataurl) {
    var arr = dataurl.split(',');
    var mime = arr[0].match(/:(.*?);/)[1];
    var bstr = window.atob(arr[1]);
    var n = bstr.length;
    var u8arr = new Uint8Array(n);
  
    while (n--) {
      u8arr[n] = bstr.charCodeAt(n);
    }
    return new Blob([u8arr], {
      type: mime
    });
  }
  </code></pre>
  
  <p>dataurl is:</p>
  
  <blockquote>
    <p>src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAgAElEQVR4Xmy9edRl6VXe95z5nHvuvd9Uc5W6q9WSWiOSGISEmCQmx2ZKCAtjsryygv9JVsY/SGwSRw54GezYBiHANEkV7WeKQBWriul64VufPLj2vMCbSUTqQU5OAPx2lIl+S0qZWAskN2jLhaZ5ioaZRZBgMbG1AL…</p>
  </blockquote>