Add encoding flag to lib/misc/file.js
Issue #22
resolved
Proposal below; thoughts? Would apply to readFile as well, I think.
writeFile: function(filePath, contents, encoding) {
var file = aeq.getFileObject(filePath);
if (!file.exists) {
var folder = new Folder( file.path );
if ( !folder.exists ) {
folder.create();
}
}
if (!aeq.isNullOrUndefined(encoding))
file.encoding = encoding;
file.open("w");
var success = file.write(contents);
file.close();
return success;
}
Comments (3)
-
-
Account Deleted reporter - changed status to resolved
misc/file.js: Adds encoding argument, defaults to UTF-8 (resolve
#22)→ <<cset 853a4c318362>>
-
- changed milestone to 1.0 Release
- Log in to comment
That's a good idea. You could maybe go further by specify a default encoding? Mac uses UTF-8 and Windows uses some other incompatible format. It would be nice if they both used UTF-8 so you don't get any errors when writing files. Can't remember now but I have had some trouble with the before and the solution was to set UTF-8 explicitly.