<%
'-------------------------------------------------
'Nombre de la función: ReadTextFile
'Función: use el objeto ADODB.Stream para leer archivos de texto de formato UTF-8
'----------------------------------------------------
functionReadFromTextFile (fileUrl, charset)
dimstratido
setstm = server.createObject ("ADODB.Stream")
stm.type = 2 'lea en este modo
stm.mode = 3
stm.charset = charset
stm.open
stm.loadFromFileserver.mappath (FileUrl)
str = stm.ReadText
stm. cerrar
setstm = nada
ReadFromTextFile = str
Función final
'-------------------------------------------------
'Nombre de la función: WriteTotExtfile
'Función: use el objeto ADODB.stream para escribir archivos de texto en formato UTF-8
'----------------------------------------------------
SubWriteTotExtFile (FileUrl, Byvalstr, Charset)
setstm = server.createObject ("ADODB.Stream")
stm.type = 2 'lea en este modo
stm.mode = 3
stm.charset = charset
stm.open
stm.writeTextstrS
stm.savetofilesserver.mappath (fileurl), 2
stm.flush
stm. cerrar
setstm = nada
Endsub
%>
<%
Dimstrtext
strText = readFromTextFile ("test_utf-8.txt", "UTF-8")
%>
<
<htmlxmlns = "http://www.w3.org/1999/xhtml">
<Evista>
<Evista>
<title> Ejemplo de código: leer/escribir archivos en formato de codificación 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"/>
</ablo>
<Body>
<%= strText%>
</body>
</html>