VB URL编码函数

小歆13年前软件源码04454
VB UTF-8 URL编码函数:
  1. Public Function UTF8_URLEncoding(szInput)
  2.     Dim wch, uch, szRet
  3.     Dim x
  4.     Dim nAsc, nAsc2, nAsc3
  5.     If szInput = "" Then
  6.         UTF8_URLEncoding = szInput
  7.         Exit Function
  8.     End If
  9.     For x = 1 To Len(szInput)
  10.         wch = Mid(szInput, x, 1)
  11.         nAsc = AscW(wch)
  12.        
  13.         If nAsc < 0 Then nAsc = nAsc + 65536
  14.        
  15.         If (nAsc And &HFF80) = 0 Then
  16.             szRet = szRet & wch
  17.         Else
  18.             If (nAsc And &HF000) = 0 Then
  19.                 uch = "%" & Hex(((nAsc \ 2 ^ 6)) Or &HC0) & Hex(nAsc And &H3F Or &H80)
  20.                 szRet = szRet & uch
  21.             Else
  22.                 uch = "%" & Hex((nAsc \ 2 ^ 12) Or &HE0) & "%" & _
  23.                 Hex((nAsc \ 2 ^ 6) And &H3F Or &H80) & "%" & _
  24.                 Hex(nAsc And &H3F Or &H80)
  25.                 szRet = szRet & uch
  26.             End If
  27.         End If
  28.     Next
  29.     UTF8_URLEncoding = szRet
  30. End Function
VB GB2312 URL编码函数:
  1.    Public Function URLEncode(ByRef strURL)
  2.        Dim I
  3.        Dim tempStr
  4.        For I = 1 To Len(strURL)
  5.            If InStr("-,.0123456789/", Mid(strURL, I, 1)) Then
  6.                URLEncode = URLEncode & Mid(strURL, I, 1)
  7.            Else
  8.                If Asc(Mid(strURL, I, 1)) < 0 Then
  9.                    tempStr = "%" & Right(CStr(Hex(Asc(Mid(strURL, I, 1)))), 2)
  10.                    tempStr = "%" & Left(CStr(Hex(Asc(Mid(strURL, I, 1)))), Len(CStr(Hex(Asc(Mid(strURL, I, 1))))) - 2) & tempStr
  11.                    URLEncode = URLEncode & tempStr
  12.                ElseIf (Asc(Mid(strURL, I, 1)) >= 65 And Asc(Mid(strURL, I, 1)) <= 90) Or (Asc(Mid(strURL, I, 1)) >= 97 And Asc(Mid(strURL, I, 1)) <= 122) Then
  13.                    URLEncode = URLEncode & Mid(strURL, I, 1)
  14.                Else
  15.                    URLEncode = URLEncode & "%" & Hex(Asc(Mid(strURL, I, 1)))
  16.                End If
  17.            End If
  18.        Next
  19.    End Function

相关文章

【经典教程】Arduino使用教程和典型范例

【经典教程】Arduino使用教程和典型范例

【经典教程】Arduino使用教程和典型范例 下载地址:     百度网盘:http://pan.baidu.com/s/1pJ6Sxib &...

VB操作INI文件方案

VB读写ini文件(1) 自从注册表诞生以来ini文件正在逐渐失去其市场占有率,然而基于ini文件的独立性,致使其还没有到达退出历史舞台的地步,很多应用程序的初始化和一些界面参数的设置仍然很愿意...

高考倒计时4.5.jpg

[小歆][高考倒计时][V4.5][终结版][2012.10.01]

高考倒计时 V4.5 终结版 软件介绍:     1.《高考倒计时 V4.5》是本软件的终结版,增强界面完美无BUG强化;   &nbs...

555集成电路应用800例.jpg

555集成电路应用800例(新编版)

555集成电路应用800例(新编版)        新编555集成电路应用800例电路4余例而成。本书在简要介绍时基电路5...

苹果4电路.jpg

iPhone4全套电路图(高清无水印)

iPhone4全套电路图   下载地址:  http://pan.baidu.com/s/1vh4gn 密码: rk9s...

小歆のBlog迁移至emlog

小歆のBlog迁移至emlog

起因 2017年1月13日小歆のBlog作为最后一个网站从BudgetVM迁移至阿里云,使用国内的服务器能够得到更好的速度体验,为了更好发挥这个优势博客站将放弃WordPress转为...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。