一个字 “燚”

unto_lg 2004-08-09 05:47:54
下面这段代码在asp中对大多数中文都可以,但为什么这个字不行呢?

高手赐教

<%
s = "燚"
Response.Write URLDecode(Server.URLEncode (s))

Function URLDecode(strIn)
URLDecode = ""
Dim sl: sl = 1
Dim tl: tl = 1
Dim key: key = "%"
Dim kl: kl = Len(key)
sl = InStr(sl, strIn, key, 1)
Do While sl>0
If (tl=1 And sl<>1) Or tl<sl Then
URLDecode = URLDecode & Mid(strIn, tl, sl-tl)
End If
Dim hh: hh = Mid(strIn, sl+kl, 2)'高位
Dim a: a = Int("&H" & hh)'ascii码
If a<128 Then
sl = sl + 3
Else
Dim hi: hi = Mid(strIn, sl+3+kl, 2)'低位
a = Int("&H" & hh & hi)'非ascii码
sl = sl + 6
End If
URLDecode = URLDecode & Chr(a)
tl = sl
sl = InStr(sl, strIn, key, 1)
Loop
URLDecode = URLDecode & Mid(strIn, tl)
End Function
%>
...全文
229 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
unto_lg 2004-08-10
  • 打赏
  • 举报
回复
给个示例代码如何,不胜感激!
unto_lg 2004-08-10
  • 打赏
  • 举报
回复
谢谢!我在网上查到一些资料,解决了,但是我还是要给你分!毕竟你多次帮助过我,而且很耐心。



Function URLDecode(enStr)
dim deStr
dim c,i,v
deStr=""
for i=1 to len(enStr)
c=Mid(enStr,i,1)
if c="%" then
v=eval("&h"+Mid(enStr,i+1,2))
if v<128 then
deStr=deStr&chr(v)
i=i+2
else
if isvalidhex(mid(enstr,i,3)) then
if isvalidhex(mid(enstr,i+3,3)) then
v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))
deStr=deStr&chr(v)
i=i+5
else
v=eval("&h"+Mid(enStr,i+1,2)+cstr(hex(asc(Mid(enStr,i+3,1)))))
deStr=deStr&chr(v)
i=i+3
end if
else
destr=destr&c
end if
end if
else
if c="+" then
deStr=deStr&" "
else
deStr=deStr&c
end if
end if
next
URLDecode=deStr
end function

function isvalidhex(str)
isvalidhex=true
str=ucase(str)
if len(str)<>3 then isvalidhex=false:exit function
if left(str,1)<>"%" then isvalidhex=false:exit function
c=mid(str,2,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
c=mid(str,3,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
end function
mjpclab 2004-08-10
  • 打赏
  • 举报
回复
...........................

If a<128 Then
sl = sl + 3
Else
Dim hi
if Mid(strIn, sl+3, 1)="%" Then
hi = Mid(strIn, sl+3+kl, 2)'低位
a = Int("&H" & hh & hi)'非ascii码
else
hi = Hex(Asc(Mid(strIn, sl+3, 1)))'低位
a = Int("&H" & hh & hi)
end if
sl = sl + 6
End If

....................................
mjpclab 2004-08-09
  • 打赏
  • 举报
回复
"燚" 用 urlencode后得到%A0D,为什么?
因为它的低8位小于127,直接转换成了"D"
所以高8位>127时,对后面的字符串还要作两种处理,分别对%xx和普通字符两种形式进行处理
unto_lg 2004-08-09
  • 打赏
  • 举报
回复
yi
chang1216 2004-08-09
  • 打赏
  • 举报
回复
这个字念什么?

28,409

社区成员

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

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