关于api接口转码的问题。。

zywandy 2014-12-22 10:27:42
最近在做一个接口。URL汉字方面出了点问题。求助
对方的接口也是GB2312的但是我GET过去总是字符丢失
代码如下

<%Const SetPageCode = "GB2312"%>

<!--#include file="admininit.asp" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />

<title></title>
</head>

<%



subUrlxiaoqu = "http://data.esf.sina.com.cn/Apisinahouse/getlikecommtodis?district=宝山&communityname=呼玛五村&agentId=5147603320&companyId=1333&signature=6b36fa1fe3bf8bf74a3fee876942acbc&dataType=json&dataType=json"
Set Retrieval = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")

Retrieval.open "GET", subUrlxiaoqu, False, "", ""
Retrieval.SetRequestHeader "Content-Type","text/html charset=gb2312"
Retrieval.send()
ResponseTxtxiaoqu = Retrieval.responseText
Set Retrieval = Nothing


Response.write ResponseTxtxiaoqu
%>




<body>



<form action="<%=ResponseTxt1%>" method="post">


<input type="submit" value="<%=ResponseTxt1%>" Method="Post"></INPUT>
</form>


</body>
</html>

这段URL在IE8里可以正常执行。但是我程序里就不行
...全文
386 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hookee 2014-12-26
  • 打赏
  • 举报
回复
你的asp文件本身的编码用UTF-8的(用记事本打开->另存为->编码选UTF-8), server.urlencode 就会编码成你要的了
xcgh 2014-12-26
  • 打赏
  • 举报
回复
中文不能在url中传递,必须转码,转码时注意对方要求的编码
zywandy 2014-12-25
  • 打赏
  • 举报
回复
引用 1 楼 hefeng_aspnet 的回复:
<a href="B.asp?leibie=<%=server.urlencode("中文字符")%>"> 中文传递URL测试</a>
---------------------------------------------------------------------------------------------------------------------------------- 但是现在就是转码后URL中文字符不一样 city = server.urlencode("上海市") area = server.urlencode("宝山") address = server.urlencode("共富四村") commname =server.urlencode("共富四村") 对方需要的链接 city=%E4%B8%8A%E6%B5%B7%E5%B8%82&area=%E6%B5%A6%E4%B8%9C&address=%E6%B5%A6%E4%B8%9C%E5%8D%97%E8%B7%AF1036%E5%BC%84&commname=%E9%9A%86%E5%AE%87%E5%A4%A7%E5%8E%A6&apikey=eec798b4dabd433b9414a304ce8e912b&sign=a7bf661d30823243c832e1634b43dcdc&ie=UTF8 我转码后的链接 city=%C9%CF%BA%A3%CA%D0&area=%B1%A6%C9%BD&address=%B9%B2%B8%BB%CB%C4%B4%E5&commname=%B9%B2%B8%BB%CB%C4%B4%E5&apikey=eec798b4dabd433b9414a304ce8e912b&sign=a7bf661d30823243c832e1634b43dcdc&ie=UTF8
csdn_aspnet 2014-12-23
  • 打赏
  • 举报
回复
<a href="B.asp?leibie=<%=server.urlencode("中文字符")%>"> 中文传递URL测试</a>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧