经典ASP的字符集包括文件

时间:2016-03-18 14:19:38

标签: utf-8 vbscript asp-classic

我们发现了一个问题,即UTF-8包含文件导致其包含的ANSI文件变为UTF-8。

包含文件是否有任何理由是UTF-8,还是可以安全地更改为ANSI?

当我尝试更改它时,没有任何明显的信息被破坏,但是包含文件包含与Web服务交互相关的功能。

我包含了包含文件的代码:

<%   
Function GetQuotedUrl(ByVal value)
    GetQuotedUrl = Chr(34) & value & Chr(34)
End Function

Function GetServiceResponse(ByVal paramArr,ByVal methodName)

    dim soapMessage
    dim responseMessage

    soapMessage=CreateSOAPMessage(paramArr,methodName)      
    soapMessage = Replace(soapMessage, "'", chr(34))

    Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")                                  
    xmlhttp.open "POST", SERVICE_URL , False
    xmlhttp.setTimeouts 30000, 60000, 30000, 120000
    xmlhttp.setRequestHeader "Man", POST & " " & SERVICE_URL & " HTTP/1.1"
    xmlhttp.setRequestHeader "SOAPAction", "http://tempuri.org/" &  SERVICE_CONTRACT & "/" & methodName
    xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"

    xmlhttp.send(soapMessage)
    responseMessage=xmlhttp.responseText        
    GetServiceResponse=responseMessage

End Function

Function CreateSOAPMessage(ByVal paramArr,ByVal methodName)

    dim soapMessage
    dim param
    dim paramName,paramValue
    dim paramNameValue

    For count=0 to UBound(paramArr)-1
      paramNameValue=Split(paramArr(count),"=")
      param = param & "<" & paramNameValue(0) & ">" & paramNameValue(1) & "</" & paramNameValue(0) & ">"
    Next

    soapMessage = "<s:Envelope xmlns:s=" & GetQuotedUrl("http://schemas.xmlsoap.org/soap/envelope/") & ">" & _ 
                    "<s:Body>" & _ 
                        "<" & methodName & " xmlns=" & GetQuotedUrl("http://tempuri.org/") & ">" & param & "</" & methodName & ">" & _
                    "</s:Body>" & _
                "</s:Envelope>"

   CreateSOAPMessage=soapMessage          

End Function       
%>

1 个答案:

答案 0 :(得分:0)

在文件中看起来不是7位ASCII范围之外的任何字符,并且由于ANSI和UTF-8在这个字符范围内共享相同的定义,所以它不应该是一个问题。你会发现一些困难,如果你的文件甚至包含像欧元符号一样无辜的字符,&#34;卷曲&#34;引用,或者破折号。这些字符从值到字形的映射在ANSI和UTF-8之间是不同的,所以你不能简单地说&#34;文件是ANSI&#34;并侥幸逃脱。