Add encoding flag to lib/misc/file.js

Issue #22 resolved
Zack Lovatt created an issue

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 ) {
        if (!aeq.isNullOrUndefined(encoding))
            file.encoding = encoding;"w");
        var success = file.write(contents);
        return success;

Comments (3)

  1. Rune Gangsø

    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.

  2. Log in to comment