.net UrlEncode - lowercase problem

后端 未结 7 977
梦如初夏
梦如初夏 2020-11-27 19:56

I\'m working on a data transfer for a gateway which requires me to send data in UrlEncoded form. However, .net\'s UrlEncode creates lowercase tags, and it breaks the transfe

7条回答
  •  时光取名叫无心
    2020-11-27 20:43

    This is the code that I'm using in a Twitter application for OAuth...

        Public Function OAuthUrlEncode(ByVal value As String) As String
        Dim result As New StringBuilder()
        Dim unreservedChars As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~"
        For Each symbol As Char In value
            If unreservedChars.IndexOf(symbol) <> -1 Then
                result.Append(symbol)
            Else
                result.Append("%"c + [String].Format("{0:X2}", AscW(symbol)))
            End If
        Next
    
        Return result.ToString()
    End Function
    

    Hope this helps!

提交回复
热议问题