The jQuery.twFile plugin does not save the file in UTF-8 format
Firefiox 11.0
checked with german chars ßüöä

After adding a converter as described in Writing a File section on
https://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO

it works :)

maybe it would be good idea to add this code to twFile plugin ?

The modified function for drivers.mozilla

                saveFile: function(filePath,content) {
                        // Returns null if it can't do it, false if there's an 
error, true
if it saved OK
                        if(window.Components) {
                                try {
        
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                                        var file = 
Components.classes["@mozilla.org/file/local;
1"].createInstance(Components.interfaces.nsILocalFile);
                                        file.initWithPath(filePath);
                                        if(!file.exists())
                                                file.create(0,0664);
                                        var out = 
Components.classes["@mozilla.org/network/file-output-
stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
                                        out.init(file,0x20|0x02,00004,null);

                                        var converter = 
Components.classes["@mozilla.org/intl/converter-
output-stream;1"].
        
createInstance(Components.interfaces.nsIConverterOutputStream);
                                        converter.init(out, "UTF-8", 0, 0);
                                        converter.writeString(content);
                                        converter.close(); // this closes 
foStream

                                        return true;
                                } catch(ex) {
                                        alert("Exception while attempting to 
save\n\n" + ex);
                                        return false;
                                }
                        }
                        return null;
                }

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywikidev?hl=en.

Reply via email to