convert utf-8 to iso-8859-1 in classic asp

前端 未结 1 430
慢半拍i
慢半拍i 2020-11-30 13:40

My site now works purely in UTF-8, but in order to send an SMS using serverXMLHTTP I need to convert my message from UTF-8 til ISO-8859-1 before sending it.

The situ

相关标签:
1条回答
  • 2020-11-30 13:47

    Your handling the client side encoding but not the server side

    It really depends on your server configuration as to how ASP is handling server requests.

    There are two parts to dealing with how IIS encodes responses;

    • What is the physical file (b.asp) encoded as (UTF-8, Windows-1252, Western European (ISO) etc). As long as the processing CodePage matches the ASP file this should not be an issue (personally I prefer to use UTF-8 and in newer IIS versions this is the default).

    • What CodePage does the ASP page expect to be processed as? (<%@ CodePage %> attribute)

    You can use the code snippet below in a test page to work out what your server defaults are;

    <%
    'Check how the server is currently encoding responses.
    
    Call Response.Write(Response.Charset)
    Call Response.Write(Response.CodePage)
    %>
    

    For the below sample to work correctly b.asp will have to be saved as 65001 (UTF-8), if you're using Visual Studio this can be done using the "Advanced Save Options" dialog (not shown on menu by default has to be added using Customise Menu options).

    <%@Language="VBScript" CodePage = 65001 %>
    <% 
    'IIS should process this page as 65001 (UTF-8), responses should be 
    'treated as 28591 (ISO-8859-1).
    
    Response.CharSet = "ISO-8859-1"
    Response.CodePage = 28591
    %>
    
    0 讨论(0)
提交回复
热议问题