我有一个使用网站进行特定查询的文件,并通过HTML标头返回所需的数据。使用提供的SQL查询将返回的数据写回文件时,它可以正常工作。如果查询中包含特殊字符,则会在该点停止。
导致问题的字符示例是“?”,“〜”,“_”。我试图找到几个回来的数据,但尚未确定一个新的功能。
目前这是我在数据出现时的导出方式:
Set objExportFile = objFso.OpenTextFile(exportFileLocation, 8, True, -1)
objExportFile.Writeline(objHead.responseText)
objExportFile.Close
谢谢,
答案 0 :(得分:0)
我会尝试一次编写一个字符,看看它是否在某处特定停止,使用cscript.exe而不是wscript.exe运行:
Set objExportFile = objFso.OpenTextFile(exportFileLocation, 8, True, -1)
sCharacterData = ""
sCharacterData = objHead.responseText 'write the response to a variable
wscript.echo("Character Length of sCharacterData: " & Len(sCharacterData))
vCharNumber = 0 'set the index
Do Until vCharNumber > Len(sCharacterData) 'loop through all the characters
sCurrentChar = Mid(sCharacterData, vCharNumber, 1)
wscript.write("CharNumber: " & vCharNumber & " Char: " & sCurrentChar)
objExportFile.Write(sCurrentChar) 'write 1 character
vCharNumber = vCharNumber + 1 'increment index
Loop
objExportFile.Close
答案 1 :(得分:0)
你可以做这样的事情
Dim BadChar(2)
Dim Char
Dim header
BadChar(0) = "?"
BadChar(1) = "~"
BadChar(2) = "_"
header = objHead.responseText
For Each Char in BadChar
If InStr(header, Char) Then
header = replace(header, Char, "")
End If
Next
Set objExportFile = objFso.OpenTextFile(exportFileLocation, 8, True, -1)
objExportFile.Writeline(header)
objExportFile.Close