文字コード変換

Sub encode_changer()
Dim Filename_s As String
Dim Filename_u As String


    Filename_s = "D:\www\public\cgi-tx\doc\sjis_file.txt"
    Filename_u = "D:\www\public\cgi-tx\doc\utf_8_file.txt"
    
    'ShiftJis_to_utf8 "shift-jis", "utf-8", Filename_s, Filename_u
    
    ShiftJis_to_utf8 "utf-8", "shift-jis", Filename_u, Filename_s
    

End Sub

Sub ShiftJis_to_utf8( _
enc_i As String, _
enc_o As String, _
Filename As String, _
Filename_out As String)

    Dim FirstObj As Object
    Dim SecondObj As Object
  
    Set FirstObj = CreateObject("ADODB.Stream")
   
    With FirstObj
        .Type = 2
        .Charset = enc_i
        .Open
        .LoadFromFile Filename
        .Position = 0
    End With
  
    Set SecondObj = CreateObject("ADODB.Stream")

    With SecondObj
        .Type = 2
        .Charset = enc_o
        .Open
    End With

    FirstObj.copyto SecondObj

    SecondObj.Position = 0
  
    SecondObj.savetofile Filename_out, 2

MsgBox "fine!"

End Sub