티스토리 뷰

'// UTF-8 파일 읽기
Function fread_utf8(fpath)
	If fpath = "" Then Exit Function

	Dim objStream, txt
	Set objStream = Server.CreateObject("ADODB.Stream")
	objStream.Mode = 3
	objStream.Type = 2 ' 텍스트 타입 (1: Bin, 2: Text)
	objStream.CharSet = "UTF-8"
	objStream.Open
	objStream.LoadFromFile Server.MapPath(fpath)
	txt = objStream.ReadText
	objStream.Close
	Set objStream = Nothing

	fread_utf8 = txt
End Function

'// UTF-8 파일 쓰기
Sub fwrite_utf8(fpath, txt)
	If fpath = "" OR txt = "" Then Exit Sub

	Dim objStream
	Set objStream = Server.CreateObject("ADODB.Stream")
	objStream.Mode = 3
	objStream.Type = 2 ' 텍스트 타입 (1: Bin, 2: Text)
	objStream.CharSet = "UTF-8"
	objStream.Open
	objStream.WriteText txt, 1
	objStream.SaveToFile Server.MapPath(fpath), 2
	objStream.Flush
	objStream.Close
	Set objStream = Nothing
End Sub
댓글