<%
'---------------------------------------------------
'Nome da função: ReadTextFile
'Função: use o objeto Adodb.stream para ler os arquivos de texto do formato UTF-8
'------------------------------------------------------
functionReadFromTextFile (fileurl, charset)
dimstr
setstm = server.createObject ("adodb.stream")
stm.Type = 2 'Leia neste modo
STM.Mode = 3
stm.charset = charset
STM.OPEN
stm.loadfromfileServer.mappath (fileurl)
str = stm.readtext
stm.close
setstm = nada
ReadfromTextFile = str
Função final
'---------------------------------------------------
'Nome da função: writEtotextfile
'Função: use o objeto Adodb.stream para gravar arquivos de texto no formato UTF-8
'------------------------------------------------------
SubwritetotextFile (Fileurl, Byvaltr, Charset)
setstm = server.createObject ("adodb.stream")
stm.Type = 2 'Leia neste modo
STM.Mode = 3
stm.charset = charset
STM.OPEN
STM.WRITETEXTSTR
STM.SAVETOFILESSERVER.MAPPATH (FILEURL), 2
stm.flush
stm.close
setstm = nada
endsub
%>
<%
DIMSTRTEXT
strText = readfromTextFile ("test_utf-8.txt", "utf-8")
%>
<!
<htmlxmlns = "http://www.w3.org/1999/xhtml">
<head>
<head>
<title> Código Exemplo: Leia/gravação Arquivos no Formato de codificação UTF-8 Usando ASP </title>
<metahttp-equiv = "content-type" content = "text/html; charset = gb2312"/>
<metaname = "autor" content = "fengyan, [email protected]">
<metaname = "copyright" content = "http://www.cnlei.com"/>
</head>
<Body>
<%= strText%>
</body>
</html>