<% text = "good" call create_utf8(text) %> <% Sub create_utf8(text) const adTypeBinary = 1 const adSaveCreateOverwrite = 2 const adModeReadWrite = 3 Set objStream = server.CreateObject("ADODB.Stream") objStream.Open objStream.CharSet = "UTF-8" 'objStream.WriteText("your text goes here") objStream.WriteText(text) objStream.SaveToFile server.mappath(".") & "/fname.txt" , adSaveCreateOverWrite objStream.Close End Sub %> |
完畢。
來源 : 這篇
http://gchandra.wordpress.com/2004/08/19/creating-utf-8-files-using-asp/
用javascript語法寫
Thank’s for this tip.
Here is hte translated version for JScript:
var adTypeBinary = 1; var adSaveCreateOverWrite = 2; var adModeReadWrite = 3; var objStream = new ActiveXObject(“ADODB.Stream”); objStream.Open(); objStream.CharSet = “UTF-8〃; objStream.WriteText(content); objStream.SaveToFile(filename, adSaveCreateOverWrite); objStream.Close(); objStream.LoadFromFile filename objStream.ReadText |
if file exists to append data
補充:
Saving FileSystemObject as UTF
(來源:http://stackoverflow.com/questions/2907466/saving-filesystemobject-as-utf)
Dim objStream Set objStream = Server.CreateObject("ADODB.Stream") objStream.Type = adTypeText objStream.Mode = adModeReadWrite objStream.Open objStream.Position = 0 objStream.Charset = "UTF-8" objStream.WriteText strContent objStream.SaveToFile strABSPath,adSaveCreateOverWrite objStream.Close Set objStream=nothing |
沒有留言:
張貼留言