title: change output file encoding in a google-script with DriveApp.createFile?
body: <p>Let's explain the context of my request : I'm trying to output the content of a google spreadsheet in a .txt tabulated file, <strong>encoded in UTF-16</strong>, because I need this charset in a later task with this .txt file. </p>
  
  <p>Actually, I've got the right output in the right folder and with the name I want ect ... but the charset is UTF-8 (i've check with an basic text editor). </p>
  
  <p><strong>The problem</strong> is I can't find any documentation about charset manipulation with google script. My only solution for now, is a basic manual charset manipulation in sublim text ...</p>
  
  <p>Here's my code (translated from french). </p>
  
  <p>Thank's for your replies ! </p>
  
  <p>Maxime</p>
  
  <pre><code>    function export() {
    //sheet manipulation part
    //Get the sheet and set data range i need
    var sheet = SpreadsheetApp.getActiveSheet();
    var range = sheet.getDataRange();
    var values = sheet.getRange(2, 1, sheet.getLastRow()-1, sheet.getLastColumn()).getValues();
    var text = values.map(function (a) {return a.join('\t');}).join('\n');
  
    //Path setting and export part
    // Get sheet info, define path and create file
    var id = SpreadsheetApp.getActiveSpreadsheet().getId();
    var idString = id.toString();
    var thisFile = DriveApp.getFileById(idString);
    var parentFold = thisFile.getParents();
    var folder = parentFold.next();
    var theId = folder.getId();
    var targetFolder = DriveApp.getFolderById(theId);
    targetFolder.createFile('liste du ' + new Date() + '.txt', text, MimeType.PLAIN_TEXT);
  }
  </code></pre>