各位大大,asp中url怎么转换编码为utf8?asp页面中页面向一个aspx页面(c#)传一个中文
不能正常接收,于是我把汉字转换,Server.UrlEncode("苏州")
接收不到.这个编码是ASCI的
而手动把中文转换为utf8编码后,是可以接收到的
asp中怎么把中文转换为utf8编码啊
各位大大,求助!!!
感激涕零
不能正常接收,于是我把汉字转换,Server.UrlEncode("苏州")
接收不到.这个编码是ASCI的
而手动把中文转换为utf8编码后,是可以接收到的
asp中怎么把中文转换为utf8编码啊
各位大大,求助!!!
感激涕零
在asp.net中用unicode解码.System.Web.HttpUtility.UrlDecode(str,System.Text.UnicodeEncoding);
我在asp.net中用HttpUtility.UrlEncode("苏州",Encoding.UTF8)转换了
然后把转换后的编码考到asp中传过来,接收到的就是正常的,也能解码
其他的编码Request.QueryString["city"].Length都直接0的
dim i
dim Str_one
dim Str_unicode
if(isnull(Str)) then
exit function
end if
for i=1 to len(Str)
Str_one=Mid(Str,i,1)
Str_unicode=Str_unicode&chr(38)
Str_unicode=Str_unicode&chr(35)
Str_unicode=Str_unicode&chr(120)
Str_unicode=Str_unicode& Hex(ascW(Str_one))
Str_unicode=Str_unicode&chr(59)
next
chinese2unicode=Str_unicode
end function
接收时:
System.Web.HttpUtility.UrlDecode(str,System.Text.Encodimg.Default);
calmzeal(demon)兄:asp.net中Encoding.Default解码和asp中是一致的
但关键是用这个编码传str接收不到,为“”。如果能正常接收到,您这个市可以的
到现在为止,unicode,ASCII,ASCI,UTF8,或者直接传中文,这么多种方法,只有UTF8正常接收到Request.QueryString["city"],然后正常解码。
'调用方法
Response.Write(GG2UTF8("中国人"))
%>
<script language="javaScript" runat="Server">
function GG2UTF8(str)
{
return encodeURIComponent(str)
}
</script>
<script language="javaScript" runat="Server">
function GB2UTF8(str)
{
return encodeURIComponent(str)
}
</script>