我的网站现在纯粹以UTF-8工作,但为了使用serverXMLHTTP发送短信,我需要在发送之前将我的消息从UTF-8转换为ISO-8859-1.
情况与此并行:
a.asp:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body>
<form method="post" action="b.asp">
<input type text name="message" value="æøå and ÆØÅ"><br>
<input type=submit>
</body>
Run Code Online (Sandbox Code Playgroud)
然后是b.asp
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head><body>
<%=konvert(request("message"))%><br>
</body>
<%
Function Konvert(sIn)
Dim oIn : Set oIn = CreateObject("ADODB.Stream")
oIn.Open
oIn.CharSet = "UTF-8"
oIn.WriteText sIn
oIn.Position = 0
oIn.CharSet = "ISO-8859-1"
Konvert = oIn.ReadText
oIn.Close
End Function
%>
Run Code Online (Sandbox Code Playgroud)
在这个展示中,我希望在b.asp中看到相同的字符串,因为我发送了一个a.asp,但是我得到了这个:
æøå and ÆØÅ
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我有很多文件作为附件存储在 Access 数据库中。我要将数据移动到 SQL 服务器,为此我需要提取附加文件并将它们转换为文件系统文件。
此代码段适用于图像和 pdf 文件,但不适用于 Word 或 Excel 等 Office 文档。我认为这与编码有关,但我没有任何线索。有任何想法吗?
Dim dbs As Database
Dim rs As Recordset
Set dbs = CurrentDb
Set rs = dbs.OpenRecordset("table1")
With rs
Do While Not .EOF
Set rsRec = rs.Fields("AttFiles").Value
While Not rsRec.EOF
NameOfFile = "C:\temp\" & rsFil.Fields("FileName")
Open NameOfFile For Binary Access Write As #1
Put #1, , rsRec.Fields("FileData").Value
Close #1
rsRec.MoveNext
Wend
.MoveNext
Loop
End With
rs.Close
dbs.Close
Run Code Online (Sandbox Code Playgroud)