don't know if most of you knows about the javascript libraries to save files.
Basically the code used to be the following:
var bb = new BlobBuilder();
bb.append(content);
var fileSaver = window.saveAs(bb.getBlob("text/plain;charset=UTF-8"), "filename.txt");
But now is like this:
var oMyBlob = new Blob([content], { type : "text/plain", endings: "transparent"});
window.saveAs(oMyBlob, "filename.txt");
Either way, whatever i use (if BlobBuilder which is deprecated or Blob), the newLines aren't being displayed, everything is saved under the same line of the text file.
Do you guys know why this is happening? Tried using different ContentTypes: text/plain, text/enricher, text/html...
None of this seems to work with the newLines. If I make an "alert(data)" that i want to save in the file, the newLines are there. When I use this library, looks like it parses the newLines or something, dunno :( Tried another charsets as well..
Thanks in advance.
don't know if most of you knows about the javascript libraries to save files.
Basically the code used to be the following:
var bb = new BlobBuilder();
bb.append(content);
var fileSaver = window.saveAs(bb.getBlob("text/plain;charset=UTF-8"), "filename.txt");
But now is like this:
var oMyBlob = new Blob([content], { type : "text/plain", endings: "transparent"});
window.saveAs(oMyBlob, "filename.txt");
Either way, whatever i use (if BlobBuilder which is deprecated or Blob), the newLines aren't being displayed, everything is saved under the same line of the text file.
Do you guys know why this is happening? Tried using different ContentTypes: text/plain, text/enricher, text/html...
None of this seems to work with the newLines. If I make an "alert(data)" that i want to save in the file, the newLines are there. When I use this library, looks like it parses the newLines or something, dunno :( Tried another charsets as well..
Thanks in advance.
Share Improve this question asked Apr 18, 2013 at 14:00 msqarmsqar 3,0406 gold badges52 silver badges100 bronze badges 4- 1 Please provide system info: client OS, server OS, on what OS is the text file made? – SPRBRN Commented Apr 18, 2013 at 14:07
- 1 nevermind!!! i've solved it, if someone is trying to solve this, i just sent the file from the controller with "\r\n" as the newline instead of "\n". And be carefull, because "\n\r" doesn't work, only \r\n would do the job. Thanks rxt for trying to help anyway. – msqar Commented Apr 18, 2013 at 14:13
- Line ending is OS dependent, Windows, Unix and I think Mac use different line ending characters. The \n will show up in Windows when you open the file with wordpad. In AIR you should use window.runtime.flash.filesystem.File.lineEnding could not find anything for ECMA JS but w3c does mention the need for a funcition for that: w3/TR/FileAPI/#convenienceAPI – HMR Commented Apr 18, 2013 at 14:38
- Line ending - that's why I asked! – SPRBRN Commented Apr 18, 2013 at 15:34
1 Answer
Reset to default 6the "\r\n" char will act as the new line character in your content passed to blob.