var text = 'Text to File'
var link = document.createElement('a');
link.download = 'file.text';
var blob = new Blob([script], {type: 'text/plain'});
link.href = window.URL.createObjectURL(blob);
link.click();

 

Posted by furiganahub
,
function lengthInUtf8Bytes(str) {
  // Matches only the 10.. bytes that are non-initial characters in a multi-byte sequence.
  var m = encodeURIComponent(str).match(/%[89ABab]/g);
  return str.length + (m ? m.length : 0);
}

 

Posted by furiganahub
,