Javascript, write to txt file save as UNICODE

前端 未结 1 1965
[愿得一人]
[愿得一人] 2021-01-17 02:52

I have 2 strings. Would like it all to first make a .txt file and then save the strings to it as unicode.

function WriteFile(file, str, str2)
{
    var tmp=r         


        
相关标签:
1条回答
  • 2021-01-17 03:32

    Both the CreateTextFile and OpenTextFile methods have a parameter that specify the encoding (ASCII or Unicode (UTF16LE))

    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var filename = "c:\\testfile.txt";
    var f = fso.OpenTextFile(filename, 2, true, -1); // -1 means unicode
    f.WriteLine("Hello world!");
    f.Close();
    
    0 讨论(0)
提交回复
热议问题