line feeds in FileSaver.js

时间:2016-12-09 12:41:40

标签: javascript filesaver.js

I'm trying FileSaver.js but when saving as text all of the linefeeds are gone. I've read good things about FileSaver.js but losing all of the line feeds so it is just one long text string is a deal breaker. I always assume that I'm doing something wrong first so I figured I'd ask. If you go to the demo https://eligrey.com/demos/FileSaver.js/ you can see the saving Text sample and if you put in 1 Enter 2 Enter 3 enter 4 enter etc it all comes out on a horizontal line. Any ideas are appreciated. I was wondering if any one else has had experience with this? Do I need to save it as xhtml? I'm using type: "text/plain;charset=utf-8" just like the demo

1 个答案:

答案 0 :(得分:1)

Do you use notepad to open the .txt files? For me the filesaver seems to be working. Try using Notepad++, notepad is limited in recognizing linebreaks from different OS systems (and the server is probably linux).

Notepad only recognises CR, LF (0x0d, 0x0a), whereas other sources might use CR only, or LF only.