[Project_owners] Saving Data

Malte Kraus firefox at maltekraus.de
Fri Dec 15 07:17:11 PST 2006


Didier Ernotte wrote:
> with
> 
>         var prefs = 
> Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("your_extension_name.");
>         prefs.setCharPref("your.sub.path.to.pref", "foo");
> and
>         var str = prefs.getCharPref("your.sub.path.to.pref");
You should never use get/setCharPref. Never! They will fail for most 
non-English languages' characters and special chars like the copyright sign.
Instead, use get/setComplexValue like this:
http://developer.mozilla.org/en/docs/Code_snippets:Preferences#nsISupportsString

Malte


More information about the Project_owners mailing list