关闭

[B/S]URL 传递中文参数

1007人阅读 评论(0) 收藏 举报

解决方法:js中传参时先对中文数据使用escape函数编码,代理中对传入数据解码

1 js中编码

var url="http://127.0.0.1/domcfg.nsf/GetUserInfo?OpenAgent&UserName=" + escape("管理员/Lotus");
var xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
xmlHttp.open("Post",url,true);   
xmlHttp.send("");

2 代理中解码

Dim ss As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument

Set db=ss.CurrentDatabase
Set doc=ss.DocumentContext

Dim strPara As String
strPara=UnEscape(doc.Query_String_Decoded(0)) 

附:UnEscape解码函数
Function UnEscape(Byval strIn As String) As String
 Dim strOut As String
 Dim strChar As String
 Dim intPos As Integer
 Dim strAsc As String
 Dim blnAsc As Integer
 Do
  intPos = intPos + 1
  strChar = Mid$(strIn, intPos, 1)
  If strChar = "" Then
   Exit Do
  Elseif strChar = "%" Then
   blnAsc = True
  Elseif blnAsc Then
   If strChar = "u" Then
    strAsc = Mid$(strIn, intPos + 1, 4)
    intPos = intPos + 4
    strOut = strOut & Uchr(Clng("&h" & strAsc))
   Else
    strAsc = Mid$(strIn, intPos, 2)
    intPos = intPos + 1
    strOut = strOut & Uchr(Clng("&h" & strAsc))
   End If
   blnAsc = False
  Else
   strOut = strOut & strChar
  End If
 Loop
 UnEscape = strOut
End Function

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:234182次
    • 积分:2709
    • 等级:
    • 排名:第13323名
    • 原创:19篇
    • 转载:100篇
    • 译文:0篇
    • 评论:30条
    最新评论
    推荐链接