1

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.

4
  • 1
    Please provide system info: client OS, server OS, on what OS is the text file made? 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. 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.org/TR/FileAPI/#convenienceAPI Commented Apr 18, 2013 at 14:38
  • Line ending - that's why I asked! Commented Apr 18, 2013 at 15:34

1 Answer 1

6

the "\r\n" char will act as the new line character in your content passed to blob.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.