inet 控件引起的字符乱码问题
VB 使用inet 控件通过ASP 页面发送数据,然后通过ASP页面写入 sql 2000 数据库。结果偶尔出现以下乱码:
1 ?QQ?
2 变频电源
3 电源
4 ?齱?
5 QQ?
6 三唑仑
7 ?QQ齱?
8 QQ表情
VB程序基本源码:
Inet1.OpenURL "http://www.xxx.cn/y.asp?id=" & Trim(Text10.Text), "Content-Type: application/x-www-form-urlencoded"
y.asp 基本源码:
'我指定了为gb2312
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
'接受上面传来的参数
Tkey=Server.HTMLEncode(Replace(Trim(request("id")),"'",""))
然后把Tkey 写入数据库... 问题就出现在Tkey 的字符问题上了。
请教高手解答!
[解决办法]
打上SP6补丁试试
[解决办法]
试试
Inet1.OpenURL "http://www.xxx.cn/y.asp?id=" & urlEncode(Trim(Text10.Text)), "Content-Type: application/x-www-form-urlencoded"
Public Function urlEncode(s As String) As StringDim tmp As StringDim c As StringDim i As LongDim L As LongDim b() As ByteOn Error GoTo errhandle If Len(s) = 0 Then Exit Function b = StrConv(s, vbFromUnicode) L = UBound(b) For i = 0 To L c = Chr(b(i)) Select Case c Case "A" To "Z", "a" To "z", "0" To "9", "-", ".", "/", ":", "=", "?", "~" ',"&" tmp = tmp + c Case Else tmp = tmp + "%" + Right("0" + Hex(b(i)), 2) If b(i) > 128 Then i = i + 1 tmp = tmp + "%" + Right("0" + Hex(b(i)), 2) End If End Select Next i urlEncode = tmp Exit Functionerrhandle: logtofile "urlEncode(" + s + ") 出现 #" & str(Err.Number) & " 意外错误: " & Err.Description urlEncode = "_" Exit FunctionEnd Function