Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Jscript How to: String encoding Converting and Save File Problem in IE 6.0?

    Hi all,

    I am writing a cross-browser(i.e. 6 and netscape 7.1) javascript program to save an XML file to local file system.

    I have an xml string like below:

    var xmlStr = "<?xml version="1.0" encoding="UTF-8"?><a>some info</a>";

    I want to save this xml file to local file system with JavaScript,

    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:
    1.
    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.

    2.
    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.

    So I am wondering how to do it in IE. or if there is some small free window utility I can call from Javascript to convert a utf-16 to utf-8?

    Thanks much,


    g.n.

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i know it's a bleeding obvious question, but have you checked out MSDN ?

  • #3
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I already checked out the MSDN and got the above approaches that not working. Do you have any other advice? Thanks!

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    sorry, but my first thought was ActiveX.

    signed java applets might be worth a look, since, I believe, they get round sandbox issues of vanilla applets (though don't quote me on this).

    i've not done what your asking before, so i've got no more advice for you. i'm only guessing in the end.

  • #5
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now I know ADODB.Stream can do the trick. Thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •