notepadlet icon indicating copy to clipboard operation
notepadlet copied to clipboard

Characters outside Latin-1 range crash the notepadlet

Open jehna opened this issue 7 years ago • 3 comments

Characters outside Latin-1 seem to crash the notepadlet on save.

Sample characters to crash the app:

✓😍🤔

jehna avatar Mar 12 '17 20:03 jehna

Error:

Uncaught DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.

jehna avatar Mar 12 '17 20:03 jehna

I have fixed this by replacing btoa code with:

   var blob = new Blob([document.documentElement.outerHTML],{type : 'text/html;charset=utf8'}); 
   var a = new FileReader();
   a.onload = function(e) {
     window.location = e.target.result;
   };
   a.readAsDataURL(blob);

Wanted to create a feature branch but couldn't figure out where is the html code :)

erdemguven avatar May 25 '17 09:05 erdemguven

@erdemguven looks good! If you want to do a PR, you can find the html code at the gh-pages branch :)

jehna avatar May 25 '17 15:05 jehna