title: How can I write a UTF-8-encoded file to the user’s computer using JavaScript on IE?
body: <p>I am writing a local file using JavaScript and I am using IE for the same.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>function savefile( f,g){
  
  var w = window.frames.w;
  if( !w ) {
      w = document.createElement( 'iframe' );
      w.id = 'w';
      w.style.display = 'none';
      document.body.insertBefore( w );
      w = window.frames.w;
      if( !w ) {
          w = window.open( '', '_temp', 'width=100,height=100' );
          if( !w ) {
              window.alert( 'Sorry, could not create file.' );
              return false;
          }
      }
  }
  
  var d = w.document;
  d.open( 'text/xml', 'replace');
  d.charset = "UTF-8";
  
  d.write(JWPFormToHTML(f));
  d.close();
  var name= g.filename.value;
  
  if( d.execCommand( 'SaveAs', false , name ) )
  {
      g.filename.value=name;
      //document.getElementById("filename").value="";
      alert('File has been saved.' );
  }
  else
  {
      alert( 'The file has not been saved.\nIs there a problem?' );
  }
  w.close();
  return false;
  }
  </code></pre>
  
  <p>The problem I am facing is the file is not getting saved as a UTF-8 encoded file, although I have added <code>&lt;meta http-equiv='Content-Type' content='text/html; charset=utf-8'&gt;</code> to it.</p>
  
  <p>Please help me on this or suggest some alternative to me.</p>
  
  <p>NOTE: I would like a file manager to open before the file gets saved as in the case of <code>execCommand</code>.</p>