problems with new line character in a text file on Windows
Posted: December 16th, 2010, 9:24 pm
hi people
I'm having an issue with a script that generates a .txt file. The script is being run on a mac and the end of line characters are fine when read on a mac but aren't being interpreted correctly on the PC (Notepad displays one very long line separated with the square box unrecognised character symbols). I've done quite a bit of searching, including these forums, and found numerous mentions of the different newline characters used by mac,unix,windows and the problems thereof but no clear solutions. any advice greatly appreciated.
below is a test script with the various linefeed options. (i've also tried a couple of different .encoding and .lineFeed options without luck)
cheers../daniel
I'm having an issue with a script that generates a .txt file. The script is being run on a mac and the end of line characters are fine when read on a mac but aren't being interpreted correctly on the PC (Notepad displays one very long line separated with the square box unrecognised character symbols). I've done quite a bit of searching, including these forums, and found numerous mentions of the different newline characters used by mac,unix,windows and the problems thereof but no clear solutions. any advice greatly appreciated.
below is a test script with the various linefeed options. (i've also tried a couple of different .encoding and .lineFeed options without luck)
cheers../daniel
Code: Select all
{
var theFile = new File (Folder.myDocuments.absoluteURI + "/test.txt");
theFile = theFile.saveDlg("Save test file.");
if (theFile != null) {
lorem = "data string";
theFile.open("w","TEXT","????");
theFile.write("///various linefeed options ///\r");
theFile.write("using \\r, " + lorem + "\r");
theFile.write("using \\n, " + lorem + "\n");
theFile.write("using \\r\\n, " + lorem + "\r\n");
theFile.write("using \\n\\r, " + lorem + "\n\r");
theFile.write("using \\f, "+ lorem + "\f");
theFile.write("using \\u000A, " + lorem + "\u000A");
theFile.write("using \\u000D, " + lorem + "\u000D");
theFile.writeln("using writeln, " + lorem);
theFile.writeln("using writeln, " + lorem);
theFile.writeln("using writeln, " + lorem);
theFile.close();
}
}