I need to move .NET code to the Compact Framework. That code uses HttpUtility.UrlEncode to encode query parameters, but System.Web isn't available on CF. What can I use instead?
A:
You can look at bundling mono's implementation (optionally simplified). I don't know how many of the dependencies you'd have to bring in, though. It may or may not be feasible.
Matthew Flaschen
2009-05-25 19:47:49
A:
You probably will have to roll your own, or even better, cheat. Using reflector you will quickly see that there are a number of overloaded methods for UrlEncode, calling the version that just expects the string paramater eventually ends up converting the string to an array of bytes and calling an internal method.
Edit: Code snippet removed in case of copyright violation...
Tim Jarvis
2009-05-25 22:38:47
Tim, including decompiled copywrited software on the web seems like a license violation to me.
Andrew Arnott
2009-05-26 14:08:19
Andrew, well...MS did release the FCL source with VS2008. However, even so, you are probably correct. Just releasing it with a commercial product does not automatically give me rights to post it I guess. I'll edit the answer just in case. (a brain fart to post it in the first place)
Tim Jarvis
2009-05-26 22:41:53
+6
A:
Use Uri.EscapeDataString. It's nearly equivalent, and probably better anyway, and is included in NetCF.
Andrew Arnott
2009-05-25 22:44:01