相关疑难解决方法(0)

在经典的asp中将utf-8转换为iso-8859-1

我的网站现在纯粹以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)

有任何想法吗?

ado serverxmlhttp character-encoding asp-classic

2
推荐指数
1
解决办法
3万
查看次数

ASP:我无法解码从utf-8到iso-8859-1的某些字符

我用这个函数来解码UTF-8:

function DecodeUTF8(s)
  dim i
  dim c
  dim n
  i = 1
  do while i <= len(s)
    c = asc(mid(s,i,1))
    if c and &H80 then
      n = 1
      do while i + n < len(s)
        if (asc(mid(s,i+n,1)) and &HC0) <> &H80 then
          exit do
        end if
        n = n + 1
      loop
      if n = 2 and ((c and &HE0) = &HC0) then
        c = asc(mid(s,i+1,1)) + &H40 * (c and &H01)
      else
        c = 191 
      end if
      s = …
Run Code Online (Sandbox Code Playgroud)

utf-8 asp-classic utf8-decode

1
推荐指数
1
解决办法
3073
查看次数