title: How to write UTF-8 or Base64 data into a file (jpg/doc/pdf) on local storage(sdcard) in Phonegap
body: <p>I am getting byte array like var byteArr=[12,-123,43,99, ...] from API,
  Then I am converting it into UTF-8 String by</p>
  
  <pre><code>     var utf8_str = String.fromCharCode.apply([], new Uint8Array(byteArr));
  </code></pre>
  
  <p>Then converting UTF-8 string to Base64 string by</p>
  
  <pre><code>      var base64_str= window.btoa(utf8_str);
  </code></pre>
  
  <p>Now I am writing UTF-8 or Base64 string to file (xyz.pdf/xyz.jpg) by FileWriter in Phonegap, but it show me blank file when open it.</p>
  
  <pre><code>function gotWriteFile(dirEntry) {
  
     dirEntry.getFile(FILE_NAME, {create: true, exclusive: false}, gotFileWriteEntry,  failWrite);
  }
  
  function gotFileWriteEntry(fileEntry) {
  
  fileEntry.createWriter(gotFileWriter, failWrite);
  }
  
  function gotFileWriter(writer) {
  
   writer.onwriteend = function(evt) {
          console.log("File write successfully....");
          hideModal();
      };
      writer.write(utf8_str);
      //writer.write(base64_str);
   }
  </code></pre>
  
  <p>What is solution guys.... ?</p>