fork(2) 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.Uri.AbsoluteUri.ToString());
  17. Console.WriteLine(builder.Query);
  18.  
  19. // Shouldn't the {, }, and '}' characters be URLEncoded? I expected the
  20. // output to be %7B%27blah%27%7D
  21. // The System.UriBuilder.Querey docs say that
  22. // "The query information is escaped according to RFC 2396"
  23. // http://msdn.microsoft.com/en-us/library/system.uribuilder.query(v=vs.110).aspx
  24. // You can test our URL encoding of these characters using a web tool like
  25. // http://m...content-available-to-author-only...b.com/eric/tools/dencoder/
  26. // or using JavaScript's encodeURI: http://j...content-available-to-author-only...e.net/7wgtJ/
  27. // or using a C# class--but unfortunately both HttpServerUtility and
  28. // WebUtility, which provide URL encoding, seem unavailable in ideone.
  29. }
  30. }
Success #stdin #stdout 0.07s 33936KB
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'}
http://w...content-available-to-author-only...g.com/?param={'blah'}
?param={'blah'}