Classic ASP 字符集包含文件

Character set of Classic ASP include files

我们发现了一个问题,即 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       
%>

文件中似乎没有任何超出 7 位 ASCII 范围的字符,并且由于 ANSI 和 UTF-8 在此字符范围内共享相同的定义,因此这应该不是问题.如果您的文件甚至包含像欧元符号、"curly" 引号或破折号这样无辜的字符,您会发现有些困难。这些字符从值到字形的映射在 ANSI 和 UTF-8 之间是不同的,所以你不能简单地说 "the file is ANSI" 并摆脱它。