5

In "regular" .NET there is a UrlEncode method that takes an Encoding parameter. Is there no such UrlEncode method in .NET for WP7?

I'm located in Sweden and I'm trying to retrieve data from a REST service that expects ISO-8859-1 in the requests (but responds in UTF-8). When doing a search (input=frölunda) and just using UrlEncode i get input=fr%C3%B6lunda which returns very strange results because of the "missing" ö. Using the .NET UrlDecode with iso-8859-1 encoding i get input=fr%F6lunda which returns the excpected results.

Do I have to implement my own UrlEncode?

jovnas
  • 384
  • 2
  • 15

1 Answers1

2

Interesting, it seems like Microsoft is following the standard here with Silverlight. Wikipedia says:

[...] should convert all other characters to bytes according to UTF-8, and then percent-encode those values. This requirement was introduced in January 2005 with the publication of RFC 3986. URI schemes introduced before this date are not affected.

So it seems like they dropped the choice of encoding since only one is allowed anyway.

Apart from that you are not the only one having this problem. The recommendation there is: don't reinvent the wheel and use code already written to get the HtmlEncode you need. (Apart from the recommendation to use Uri.EscapeUriString instead of HttpUtility.UrlEncode on the client side - but I can't judge that.)

Community
  • 1
  • 1
Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85
  • 1
    So the problem is actually that the REST service provider is not following the current standard. I'll drop them a line and see what they can do. (And if that fails I'll borrow the GData implementation.) Thanks for the info! – jovnas Dec 11 '11 at 20:05
  • 1
    So it seems. Good luck persuading them! – Heinrich Ulbricht Dec 11 '11 at 20:10