Unicode to UTF-8

前端 未结 2 2015
無奈伤痛
無奈伤痛 2021-01-02 12:11

i\'m using vbscript to extract data from db2 and write to file. Writing to file like:

Set objTextFile = objFSO.CreateTextFile(sFilePath, True, True)
         


        
2条回答
  •  迷失自我
    2021-01-02 12:22

    Using the Stream object to save your file with the utf-8 charset might work better for you; here's a simple .vbs function you could test out on your data:

    Option Explicit
    
    Sub Save2File (sText, sFile)
        Dim oStream
        Set oStream = CreateObject("ADODB.Stream")
        With oStream
            .Open
            .CharSet = "utf-8"
            .WriteText sText
            .SaveToFile sFile, 2
        End With
        Set oStream = Nothing
    End Sub
    
    ' Example usage: '
    Save2File "The data I want in utf-8", "c:\test.txt"
    

提交回复
热议问题