"http://test# space 123/text?var=val&another=two"
"http://www.google.com/helloworld?var=value#abcdefg=hello world"
"http://example.org/foo/bar;param?query#frag"
"http://www.permadi.com/tutorial/urlEncoding/example.html?var=This is a simple & short test."
"""http://www.permadi.com/tutorial/urlEncoding/example.html?var=$ & < > ? ; # : = , " ' ~ + %""" (* hack fix the syntax highlighter """ " """ *)
let printvalue a (b:string) =
let bad = b.Contains(" ")
let display = if bad then "invalid" else ""
printfn "\t%-20s%-10s%20s" a display b
printvalue "UrlEncode" (HttpUtility.UrlEncode t)
printvalue "EscapeUriString" (Uri.EscapeUriString t)
printvalue "EscapeDataString" (Uri.EscapeDataString t)
printvalue "EscapeDataReplace" (Uri.EscapeDataString t |> (fun e-> e.Replace("%20","+")))
printvalue "HtmlEncode" (HttpUtility.HtmlEncode t)
printvalue "UrlPathEncode" (HttpUtility.UrlPathEncode t)