Welcome to WebmasterWorld Guest from 184.108.40.206
Forum Moderators: open
I have an xml string like below:
var xmlStr = "<?xml version="1.0" encoding="UTF-8"?><a>some info</a>";
in Netscape 7.1, this is easy with XPCOM:
var uConv = Components.classes['@mozilla.org/intl/scriptableunicodeconverter'].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
//uConv = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIUTF8ConverterService);
uConv.charset = "UTF-8";
var xmlStrUTF8 = uConv.ConvertFromUnicode(fileStr);
then save the utf-8 encoded file to local file system.
But how can I do the same stuff in IE 6.0?
I tried two approaches but not working:
convert the xml string to XML DOM object, try to use the XML DOM save method, but IE6.0 use msxml 3.0 and it doesn't work by calling save() from browser due to security issue.
using ActiveX filesystem object's createTextFile method, then call write() method. But the problem is the write() method only can save a text file with ASCII encoding or utf-16 encoding. My xml file needs "utf-8" encoding.