Hi guys, I have a method that encodes a Url. I want to convert it to C# normally I dont have a issue with things like this but it looks like it is calling itself without a value passed, very strange looking. Any tips on how to convert are much appreciated.
Code:Function URLEncode(ByVal Text As String) As String Dim i As Integer Dim acode As Integer 'Dim char As String URLEncode = Text For i = Len(URLEncode) To 1 Step -1 acode = Asc(Mid$(URLEncode, i, 1)) Select Case acode Case 48 To 57, 65 To 90, 97 To 122 ' don't touch alphanumeric chars Case 32 URLEncode = URLEncode.Substring(0, i - 1) & "+" & Mid(URLEncode, i + 1) ' replace space with "+" Case Else ' replace punctuation chars with "%hex" URLEncode = URLEncode.Substring(0, i - 1) & "%" & Hex$(acode) & Mid$(URLEncode, i + 1) End Select ' End If Next If InStr(URLEncode, "%D%A") Then URLEncode = Replace(URLEncode, "%D%A", "%0D%0A") End If End Function




Reply With Quote