Skip to content

Instantly share code, notes, and snippets.

@gazhikaba
Created April 20, 2016 12:20
Show Gist options
  • Select an option

  • Save gazhikaba/fd28f8935aa2da08e6667b4b2a107a78 to your computer and use it in GitHub Desktop.

Select an option

Save gazhikaba/fd28f8935aa2da08e6667b4b2a107a78 to your computer and use it in GitHub Desktop.
VBA
.LineSeparator
Function SJIS_to_UTF8(FN As String)
引数「FN」にファイルのフルパスを入れます。
Dim FROM_OBJ As Object
Dim TO_OBJ As Object
Set FROM_OBJ = CreateObject("ADODB.Stream")
With FROM_OBJ
.Type = 2
.Charset = "shift-jis"
.Open
.LoadFromFile FN
.LineSeparator = 10 '10:LF 13:CR -1:CRLF
.Position = 0
End With
Set TO_OBJ = CreateObject("ADODB.Stream")
With TO_OBJ
.Type = 2
.Charset = "utf-8"
.Open
End With
FROM_OBJ.copyto TO_OBJ
TO_OBJ.Position = 0
TO_OBJ.savetofile FN & "_utf.txt", 2
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment