I am using the following work to save the text in the file (on IE-8 w / ActiveX).
function savefile (strobel path, strontant) {var fso = new ActiveXObject ("Scripting.FileSystemObject"); Var flOutput = fso.CreateTextFile (strFullPath, true); To overwrite FlOutput.write (strContent) / flOutput.Close (); }
This code works fine if the text is completely Latin 9, but when the text contains a single UTF-8 encoded character, the writing fails.
ActiveX FileSystemObject does not support UTF-8, it seems I tried to read UTF-16 encoding for the first time but the result was messy. What is an alternative solution?
Try it out:
function savefile (strFullPath, strContent) { Var fso = new ActiveXObject ("Scripting.FileSystemObject"); Var utf8Enc = New ActiveXObject ("Utf8Lib.Utf8Enc"); Var flOutput = fso.CreateTextFile (strFullPath, true); To overwrite the flow output / true. BinaryWrite (utf8Enc.UnicodeToUtf8 (strContent)); FlOutput.Close (); }
Comments
Post a Comment