[asp]unicode文件转ascii文件函数

Function UnicodeToAsciiFile(strFileName)
	'先打开unicode的文件
	set fso = CreateObject("Scripting.FileSystemObject")
	set unicodefile = fso.opentextfile(server.MapPath(strFileName),1,false,-1)'-1是指用unicode方式打开
	
	Dim strFileText
	strFileText = unicodefile.ReadAll'读出文本
	unicodefile.close
	set unicodefile = nothing
	
	response.write strFileText'输出一下文本
	
	'写成ascii的文件
	set fso2 = CreateObject("Scripting.FileSystemObject")
	'Set asciifile = fso2.CreateTextFile(server.MapPath("unicode2ascii.txt"), TRUE , false)
	Set asciifile = fso2.CreateTextFile(server.MapPath(strFileName), TRUE , false)
	asciifile.write strFileText
	asciifile.close
	set unicodefile = nothing
End function

Leave a Reply