
转换编码 不是直接保存的。用代码转换
比如gb2312转成utf-8的 就在每个页面顶部加上
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Session.CodePage=65001 %>
<% Response.charset = "utf-8" %>
这样才不会出现乱码的情况
你是Ajax发送数据的吧,试试将输出值进行编码了再写出。js获取后会自动进行解码,然后输出就是原样了提供个asp的编码函数你试试,可以将它包含的公共文件中Function jsEncode(str)Dim i, j, aL1, aL2, c, p
aL1 = Array(&h22, &h5C, &h2F, &h08, &h0C, &h0A, &h0D, &h09)
aL2 = Array(&h22, &h5C, &h2F, &h62, &h66, &h6E, &h72, &h74)
For i = 1 To Len(str)
p = True
c = Mid(str, i, 1)
For j = 0 To 7
If c = Chr(aL1(j)) Then
jsEncode = jsEncode &"\" &Chr(aL2(j))
p = False
Exit For
End If
Next
If p Then
Dim a
a = AscW(c)
If a >31 And a <127 Then
jsEncode = jsEncode &c
ElseIf a >-1 Or a <65535 Then
jsEncode = jsEncode &"\u" &String(4 - Len(Hex(a)), "0") &Hex(a)
End If
End If
Next
End Function Response.Write("Text=汉字&UserID=0001&UserName=" &jsEncode( rs("username")))
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)