fork(3) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. var baseUrl = new System.Uri("http://w...content-available-to-author-only...g.com");
  8. var builder = new System.UriBuilder(baseUrl);
  9. string name = "param";
  10. string val = "{'blah'}";
  11. builder.Query = name + "=" + val;
  12.  
  13. // Try several different ouput methods
  14. Console.WriteLine(builder.ToString());
  15. Console.WriteLine(builder.Uri.ToString());
  16. Console.WriteLine(builder.Query);
  17.  
  18. // Shouldn't the {, }, and '}' characters be URLEncoded? I expected the
  19. // output to be %7B%27blah%27%7D
  20. // The System.UriBuilder.Querey docs say that
  21. // "The query information is escaped according to RFC 2396"
  22. // http://msdn.microsoft.com/en-us/library/system.uribuilder.query(v=vs.110).aspx
  23. // You can test our URL encoding of these characters using a web tool like
  24. // http://m...content-available-to-author-only...b.com/eric/tools/dencoder/
  25. // or using JavaScript's encodeURI: http://j...content-available-to-author-only...e.net/7wgtJ/
  26. // or using a C# class--but unfortunately both HttpServerUtility and
  27. // WebUtility, which provide URL encoding, seem unavailable in ideone.
  28. }
  29. }
Success #stdin #stdout 0.08s 34104KB
stdin
Standard input is empty
stdout
http://w...content-available-to-author-only...g.com:80/?param={'blah'}
http://w...content-available-to-author-only...g.com/?param={'blah'}
?param={'blah'}