Save into file
#100
-
I use this code to save a string into a file: var ostream = Cc['@mozilla.org/network/file-output-stream;1'].createInstance(Ci.nsIFileOutputStream);
ostream.init(file, -1, -1, 0);
var converter = Cc['@mozilla.org/intl/scriptableunicodeconverter'].createInstance(Ci.nsIScriptableUnicodeConverter);
converter.charset = 'UTF-8';
var istream = converter.convertToInputStream(content);
NetUtil.asyncCopy(istream, ostream) Starting with FF119, the function converter.convertToInputStream don't exist anymore. I'd try istream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
istream.data = content but I have problems with characters like á, ó, ñ etc Does anyone have any idea how to continue? |
Beta Was this translation helpful? Give feedback.
Answered by
117649
Sep 27, 2023
Replies: 2 comments 4 replies
-
by Mozilla: const istream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
istream.setUTF8Data(codeElementWrapper.value); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sdavidg
-
I was testing this one: function encode_utf8(s) {
return unescape(encodeURIComponent(s));
}
var istream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
istream.data = encode_utf8(text); But your solution is very handy and better Thanks |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
by Mozilla: