String Encode and Decode

djlactose

New member
Joined
Sep 25, 2009
Messages
3
Programming Experience
10+
I am trying to write a function which has the ability to decode a string from utf8. I am getting the string as a response from a webserver.

I am using the following line to do the decoding:

VB.NET:
DecodeReply += System.Text.Encoding.ASCII.GetString(System.Text.Encoding.UTF8.GetBytes(temparray(i).ToString))

The string I am trying to decode looks like the following:
VB.NET:
FinalStatus=problem&auth%2dmsg=%20IP%20Not%20registered%20to%20username%2e%20Please%20register%2069%2e123%2e185%2e67%20in%20your%20admin%20area%2e&currency=usd&enddate=20090924&merchant=pnpdemo&mode=query_trans&publisher%2dname=pnpdemo&resphash=f1a77bfd0543078681db6e4a62f4a2cb&startdate=20090918&success=problem&MErrMsg=IP%20Not%20registered%20to%20username%2e%20Please%20register%2069%2e123%2e185%2e67%20in%20your%20admin%20area%2e&a=b
 
The question is not clear, here reply to one interpretation. Use HttpUtility class (System.Web) and UrlDecode method to get the plain string, same class and ParseQueryString method to get the name/value pairs.
VB.NET:
Dim s As String = "FinalStatus=problem&auth%2dmsg=%20IP%20Not%20registered%20to%20blah"
s = System.Web.HttpUtility.UrlDecode(s)
Dim pairs As Specialized.NameValueCollection = System.Web.HttpUtility.ParseQueryString(s)
 
The question is not clear, here reply to one interpretation. Use HttpUtility class (System.Web) and UrlDecode method to get the plain string, same class and ParseQueryString method to get the name/value pairs.
VB.NET:
Dim s As String = "FinalStatus=problem&auth%2dmsg=%20IP%20Not%20registered%20to%20blah"
s = System.Web.HttpUtility.UrlDecode(s)
Dim pairs As Specialized.NameValueCollection = System.Web.HttpUtility.ParseQueryString(s)

That code was what I had when I originally create this app as an asp page but now it is a windows program and I get Error "'HttpUtility' is not a member of 'Web'" when I try to use it.
 
System.Web is not referenced in Forms projects by default, you have to add reference to it before you can use it.
 
System.Web is not referenced in Forms projects by default, you have to add reference to it before you can use it.

I am trying to create code samples for an API so I am trying not to use anything outside of the standard stuff. There is no way other way?
 
Back
Top