R
Ron Clabo
I have a URL Decoding issue.
The text that needs to be decoded is: "123+H%F6gbergsgatan+st"
The decoded version should equate to: "123 Högbergsgatan st"
This is what I tried:
string encodedText = "123+H%F6gbergsgatan+st";
string decodedText =
System.Web.HttpUtility.UrlDecode(encodedText,System.Text.Encoding.UTF8);
However, it does not work! decodedText ends up being "123 Hgbergsgatan st"
i.e. the ö is omitted.
So to verify that the original text was encoded properly I referenced this
website: http://www.w3schools.com/html/html_ref_urlencode.asp It has a
place where you can paste in a string and click a button to see it's URL
encoded version. Sure enough, the correct url encoding for "123
Högbergsgatan st" is "123+H%F6gbergsgatan+st". As an aside, I also tried
pasting the text into a google search box to see how it got encoded in the
google url. Same encoding. So if it's incoded right, why can't I decode it
in .net?
Still frustrated, I tried using .net to encode the source string (i.e. "123
Högbergsgatan st" to see how it encoded it.
string origText = "123 Högbergsgatan st ";
string encodedText =
System.Web.HttpUtility.UrlEncode(origText,System.Text.Encoding.UTF8);
And low and behold it encoded it different. It encoded it as
"123+H%c3%b6gbergsgatan+st"!!!
I have two questions! How do I get .net to encode it as
"123+H%F6gbergsgatan+st" ? and also when I have a string
"123+H%F6gbergsgatan+st" how do it get .net to decode it as "123
Högbergsgatan st" ?
-Ron
The text that needs to be decoded is: "123+H%F6gbergsgatan+st"
The decoded version should equate to: "123 Högbergsgatan st"
This is what I tried:
string encodedText = "123+H%F6gbergsgatan+st";
string decodedText =
System.Web.HttpUtility.UrlDecode(encodedText,System.Text.Encoding.UTF8);
However, it does not work! decodedText ends up being "123 Hgbergsgatan st"
i.e. the ö is omitted.
So to verify that the original text was encoded properly I referenced this
website: http://www.w3schools.com/html/html_ref_urlencode.asp It has a
place where you can paste in a string and click a button to see it's URL
encoded version. Sure enough, the correct url encoding for "123
Högbergsgatan st" is "123+H%F6gbergsgatan+st". As an aside, I also tried
pasting the text into a google search box to see how it got encoded in the
google url. Same encoding. So if it's incoded right, why can't I decode it
in .net?
Still frustrated, I tried using .net to encode the source string (i.e. "123
Högbergsgatan st" to see how it encoded it.
string origText = "123 Högbergsgatan st ";
string encodedText =
System.Web.HttpUtility.UrlEncode(origText,System.Text.Encoding.UTF8);
And low and behold it encoded it different. It encoded it as
"123+H%c3%b6gbergsgatan+st"!!!
I have two questions! How do I get .net to encode it as
"123+H%F6gbergsgatan+st" ? and also when I have a string
"123+H%F6gbergsgatan+st" how do it get .net to decode it as "123
Högbergsgatan st" ?
-Ron