devxlogo

URLPathEncode – Convert a string for using on a URL path

' convert a string so that it can be used on a URL path'' Same effect as the Server.URLPathEncode method in ASPFunction URLPathEncode(ByVal Text As String) As String    Dim i As Integer    Dim acode As Integer        URLPathEncode = Text        For i = Len(URLPathEncode) To 1 Step -1        acode = Asc(Mid$(URLPathEncode, i, 1))        Select Case acode            Case 48 To 57, 65 To 90, 97 To 122                ' don't touch alphanumeric chars            Case 33, 35, 36, 38, 42, 43, 45, 46, 47, 58, 63, 64, 95, 126                ' these punctuation chars require no translation            Case Else                ' replace other chars with "%hex"                URLPathEncode = Left$(URLPathEncode, i - 1) & "%" & Hex$(acode) _                    & Mid$(URLPathEncode, i + 1)        End Select    Next    End Function

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Five Early Architecture Decisions That Quietly Get Expensive

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.